diff options
Diffstat (limited to 'db/post_migrate/20200506125731_cleanup_user_highest_roles_population.rb')
-rw-r--r-- | db/post_migrate/20200506125731_cleanup_user_highest_roles_population.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/db/post_migrate/20200506125731_cleanup_user_highest_roles_population.rb b/db/post_migrate/20200506125731_cleanup_user_highest_roles_population.rb new file mode 100644 index 00000000000..5e613228c56 --- /dev/null +++ b/db/post_migrate/20200506125731_cleanup_user_highest_roles_population.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class CleanupUserHighestRolesPopulation < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_for_migrating_user_highest_roles_table' + + disable_ddl_transaction! + + def up + Gitlab::BackgroundMigration.steal('PopulateUserHighestRolesTable') + + remove_concurrent_index(:users, :id, name: INDEX_NAME) + end + + def down + add_concurrent_index(:users, + :id, + where: "state = 'active' AND user_type IS NULL AND bot_type IS NULL AND ghost IS NOT TRUE", + name: INDEX_NAME) + end +end |