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:
Diffstat (limited to 'db/migrate/20210421022010_add_index_for_dormant_users.rb')
-rw-r--r--db/migrate/20210421022010_add_index_for_dormant_users.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/db/migrate/20210421022010_add_index_for_dormant_users.rb b/db/migrate/20210421022010_add_index_for_dormant_users.rb
new file mode 100644
index 00000000000..48eff184ca0
--- /dev/null
+++ b/db/migrate/20210421022010_add_index_for_dormant_users.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddIndexForDormantUsers < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ INDEX_NAME = 'index_users_on_id_and_last_activity_on_for_non_internal_active'
+
+ disable_ddl_transaction!
+
+ def up
+ index_condition = "state = 'active' AND (users.user_type IS NULL OR users.user_type IN (NULL, 6, 4))"
+
+ add_concurrent_index :users, [:id, :last_activity_on], where: index_condition, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :users, INDEX_NAME
+ end
+end