summaryrefslogtreecommitdiff
path: root/db/post_migrate/20220113111440_schedule_fix_incorrect_max_seats_used.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/post_migrate/20220113111440_schedule_fix_incorrect_max_seats_used.rb')
-rw-r--r--db/post_migrate/20220113111440_schedule_fix_incorrect_max_seats_used.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/db/post_migrate/20220113111440_schedule_fix_incorrect_max_seats_used.rb b/db/post_migrate/20220113111440_schedule_fix_incorrect_max_seats_used.rb
new file mode 100644
index 00000000000..f39b026bd77
--- /dev/null
+++ b/db/post_migrate/20220113111440_schedule_fix_incorrect_max_seats_used.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class ScheduleFixIncorrectMaxSeatsUsed < Gitlab::Database::Migration[1.0]
+ DOWNTIME = false
+ TMP_IDX_NAME = 'tmp_gitlab_subscriptions_max_seats_used_migration'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :gitlab_subscriptions, :id, where: "start_date >= '2021-08-02' AND start_date <= '2021-11-20' AND max_seats_used != 0 AND max_seats_used > seats_in_use AND max_seats_used > seats", name: TMP_IDX_NAME
+
+ return unless Gitlab.com?
+
+ migrate_in(1.hour, 'FixIncorrectMaxSeatsUsed')
+ end
+
+ def down
+ remove_concurrent_index_by_name :gitlab_subscriptions, TMP_IDX_NAME
+ end
+end