Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-12-20 17:22:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-20 17:22:11 +0300
commit0c872e02b2c822e3397515ec324051ff540f0cd5 (patch)
treece2fb6ce7030e4dad0f4118d21ab6453e5938cdd /db/post_migrate/20221210154044_update_active_billable_users_index.rb
parentf7e05a6853b12f02911494c4b3fe53d9540d74fc (diff)
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'db/post_migrate/20221210154044_update_active_billable_users_index.rb')
-rw-r--r--db/post_migrate/20221210154044_update_active_billable_users_index.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/db/post_migrate/20221210154044_update_active_billable_users_index.rb b/db/post_migrate/20221210154044_update_active_billable_users_index.rb
new file mode 100644
index 00000000000..9d306eff16b
--- /dev/null
+++ b/db/post_migrate/20221210154044_update_active_billable_users_index.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+class UpdateActiveBillableUsersIndex < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ OLD_INDEX_NAME = 'active_billable_users'
+ NEW_INDEX_NAME = 'index_users_for_active_billable'
+ TABLE_NAME = 'users'
+ COLUMNS = %i[id]
+ OLD_INDEX_FILTER_CONDITION = <<~QUERY
+ ((state)::text = 'active'::text) AND ((user_type IS NULL)
+ OR (user_type = ANY (ARRAY[NULL::integer, 6, 4]))) AND ((user_type IS NULL)
+ OR (user_type <> ALL ('{2,6,1,3,7,8}'::smallint[])))
+ QUERY
+ NEW_INDEX_FILTER_CONDITION = <<~QUERY
+ ((state)::text = 'active'::text) AND ((user_type IS NULL)
+ OR (user_type = ANY (ARRAY[NULL::integer, 6, 4]))) AND ((user_type IS NULL)
+ OR (user_type <> ALL ('{1,2,3,4,5,6,7,8,9,11}'::smallint[])))
+ QUERY
+
+ def up
+ add_concurrent_index(TABLE_NAME, COLUMNS, where: NEW_INDEX_FILTER_CONDITION, name: NEW_INDEX_NAME)
+ remove_concurrent_index_by_name(TABLE_NAME, OLD_INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index(TABLE_NAME, COLUMNS, where: OLD_INDEX_FILTER_CONDITION, name: OLD_INDEX_NAME)
+ remove_concurrent_index_by_name(TABLE_NAME, NEW_INDEX_NAME)
+ end
+end