summaryrefslogtreecommitdiff
path: root/db/migrate/20200317110602_add_migrating_user_highest_roles_table_index_to_users.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-01 15:07:45 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-01 15:07:45 +0000
commit1219a9dce91f4edbc135dfc08299b4122b4825a8 (patch)
treee7d12a55d75a2d56e60d9527bef3724e3578866d /db/migrate/20200317110602_add_migrating_user_highest_roles_table_index_to_users.rb
parent1a0d6dbdc2ac3047f4953a359ef27ba6e26074ae (diff)
downloadgitlab-ce-1219a9dce91f4edbc135dfc08299b4122b4825a8.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db/migrate/20200317110602_add_migrating_user_highest_roles_table_index_to_users.rb')
-rw-r--r--db/migrate/20200317110602_add_migrating_user_highest_roles_table_index_to_users.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/db/migrate/20200317110602_add_migrating_user_highest_roles_table_index_to_users.rb b/db/migrate/20200317110602_add_migrating_user_highest_roles_table_index_to_users.rb
new file mode 100644
index 00000000000..e67dc323c39
--- /dev/null
+++ b/db/migrate/20200317110602_add_migrating_user_highest_roles_table_index_to_users.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+# See https://docs.gitlab.com/ee/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddMigratingUserHighestRolesTableIndexToUsers < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_for_migrating_user_highest_roles_table'
+
+ disable_ddl_transaction!
+
+ def up
+ 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
+
+ def down
+ remove_concurrent_index :users, :id, name: INDEX_NAME
+ end
+end