summaryrefslogtreecommitdiff
path: root/db/post_migrate/20200824130028_remove_index_on_users_bio.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/post_migrate/20200824130028_remove_index_on_users_bio.rb')
-rw-r--r--db/post_migrate/20200824130028_remove_index_on_users_bio.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/db/post_migrate/20200824130028_remove_index_on_users_bio.rb b/db/post_migrate/20200824130028_remove_index_on_users_bio.rb
new file mode 100644
index 00000000000..d41734eb9ce
--- /dev/null
+++ b/db/post_migrate/20200824130028_remove_index_on_users_bio.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class RemoveIndexOnUsersBio < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ BACKGROUND_MIGRATION_CLASS = 'MigrateUsersBioToUserDetails'
+ INDEX_NAME = 'tmp_idx_on_user_id_where_bio_is_filled'
+
+ disable_ddl_transaction!
+
+ def up
+ Gitlab::BackgroundMigration.steal(BACKGROUND_MIGRATION_CLASS)
+ remove_concurrent_index_by_name(:users, INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index :users, :id, where: "(COALESCE(bio, '') IS DISTINCT FROM '')", name: INDEX_NAME
+ end
+end