summaryrefslogtreecommitdiff
path: root/db/post_migrate/20220212120735_schedule_fix_incorrect_max_seats_used2.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-02-18 09:45:46 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-02-18 09:45:46 +0000
commita7b3560714b4d9cc4ab32dffcd1f74a284b93580 (patch)
tree7452bd5c3545c2fa67a28aa013835fb4fa071baf /db/post_migrate/20220212120735_schedule_fix_incorrect_max_seats_used2.rb
parentee9173579ae56a3dbfe5afe9f9410c65bb327ca7 (diff)
downloadgitlab-ce-a7b3560714b4d9cc4ab32dffcd1f74a284b93580.tar.gz
Add latest changes from gitlab-org/gitlab@14-8-stable-eev14.8.0-rc42
Diffstat (limited to 'db/post_migrate/20220212120735_schedule_fix_incorrect_max_seats_used2.rb')
-rw-r--r--db/post_migrate/20220212120735_schedule_fix_incorrect_max_seats_used2.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/db/post_migrate/20220212120735_schedule_fix_incorrect_max_seats_used2.rb b/db/post_migrate/20220212120735_schedule_fix_incorrect_max_seats_used2.rb
new file mode 100644
index 00000000000..c8a6bd0a15d
--- /dev/null
+++ b/db/post_migrate/20220212120735_schedule_fix_incorrect_max_seats_used2.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class ScheduleFixIncorrectMaxSeatsUsed2 < Gitlab::Database::Migration[1.0]
+ MIGRATION = 'FixIncorrectMaxSeatsUsed'
+ TMP_IDX_NAME = 'tmp_gitlab_subscriptions_max_seats_used_migration_2'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :gitlab_subscriptions, :id, where: "start_date < '2021-08-02' 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, MIGRATION, ['batch_2_for_start_date_before_02_aug_2021'])
+ end
+
+ def down
+ remove_concurrent_index_by_name :gitlab_subscriptions, TMP_IDX_NAME
+ end
+end