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/post_migrate/20200608203426_set_proper_lock_version_indices.rb')
-rw-r--r--db/post_migrate/20200608203426_set_proper_lock_version_indices.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/db/post_migrate/20200608203426_set_proper_lock_version_indices.rb b/db/post_migrate/20200608203426_set_proper_lock_version_indices.rb
new file mode 100644
index 00000000000..924ca73e6cc
--- /dev/null
+++ b/db/post_migrate/20200608203426_set_proper_lock_version_indices.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class SetProperLockVersionIndices < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index :epics, :lock_version, where: "lock_version IS NULL"
+ remove_concurrent_index :merge_requests, :lock_version, where: "lock_version IS NULL"
+ remove_concurrent_index :issues, :lock_version, where: "lock_version IS NULL"
+
+ add_concurrent_index :epics, :id, where: "lock_version IS NULL", name: 'index_epics_on_id'
+ add_concurrent_index :merge_requests, :id, where: "lock_version IS NULL", name: 'index_merge_requests_on_id'
+ add_concurrent_index :issues, :id, where: "lock_version IS NULL", name: 'index_issues_on_id'
+ end
+
+ def down
+ add_concurrent_index :epics, :lock_version, where: "lock_version IS NULL"
+ add_concurrent_index :merge_requests, :lock_version, where: "lock_version IS NULL"
+ add_concurrent_index :issues, :lock_version, where: "lock_version IS NULL"
+
+ remove_concurrent_index_by_name :epics, name: 'index_epics_on_id'
+ remove_concurrent_index_by_name :merge_requests, name: 'index_merge_requests_on_id'
+ remove_concurrent_index_by_name :issues, name: 'index_issues_on_id'
+ end
+end