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/20201120125953_replace_unused_labels_index.rb')
-rw-r--r--db/migrate/20201120125953_replace_unused_labels_index.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/db/migrate/20201120125953_replace_unused_labels_index.rb b/db/migrate/20201120125953_replace_unused_labels_index.rb
new file mode 100644
index 00000000000..afddbce618d
--- /dev/null
+++ b/db/migrate/20201120125953_replace_unused_labels_index.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class ReplaceUnusedLabelsIndex < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ NEW_INDEX_NAME = 'index_labels_on_group_id_and_title_with_null_project_id'
+ OLD_INDEX_NAME = 'index_labels_on_group_id_and_title'
+
+ def up
+ add_concurrent_index :labels, [:group_id, :title], where: 'project_id IS NULL', name: NEW_INDEX_NAME
+ remove_concurrent_index_by_name :labels, OLD_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :labels, [:group_id, :title], where: 'project_id = NULL::integer', name: OLD_INDEX_NAME
+ remove_concurrent_index_by_name :labels, NEW_INDEX_NAME
+ end
+end