summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2019-07-23 14:00:06 +0000
committerNick Thomas <nick@gitlab.com>2019-07-23 14:00:06 +0000
commit31335ea661ea27d7bed3990346f63aabcc2140a5 (patch)
tree57e207ea8290059ba728dcf8f9f5afc7c797804e /db
parent76d3b35cb6082d44188cb1c61d1bff0335e6646d (diff)
parentb0eafaaca10ce291490ee8b69cae0ce7592c1694 (diff)
downloadgitlab-ce-31335ea661ea27d7bed3990346f63aabcc2140a5.tar.gz
Merge branch 'bw-add-index-for-relative-position' into 'master'
Add index for issues on relative position, project, and state for manual sorting See merge request gitlab-org/gitlab-ce!30542
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20190709220143_add_index_to_issues_relative_position.rb20
-rw-r--r--db/schema.rb1
2 files changed, 21 insertions, 0 deletions
diff --git a/db/migrate/20190709220143_add_index_to_issues_relative_position.rb b/db/migrate/20190709220143_add_index_to_issues_relative_position.rb
new file mode 100644
index 00000000000..effab33ce4f
--- /dev/null
+++ b/db/migrate/20190709220143_add_index_to_issues_relative_position.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddIndexToIssuesRelativePosition < ActiveRecord::Migration[5.1]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_issues_on_project_id_and_state_and_rel_position_and_id'.freeze
+
+ def up
+ add_concurrent_index :issues, [:project_id, :state, :relative_position, :id], order: { id: :desc }, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :issues, INDEX_NAME
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 79cd1a3a797..681353121db 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -1682,6 +1682,7 @@ ActiveRecord::Schema.define(version: 2019_07_15_114644) do
t.index ["project_id", "created_at", "id", "state"], name: "index_issues_on_project_id_and_created_at_and_id_and_state", using: :btree
t.index ["project_id", "due_date", "id", "state"], name: "idx_issues_on_project_id_and_due_date_and_id_and_state_partial", where: "(due_date IS NOT NULL)", using: :btree
t.index ["project_id", "iid"], name: "index_issues_on_project_id_and_iid", unique: true, using: :btree
+ t.index ["project_id", "state", "relative_position", "id"], name: "index_issues_on_project_id_and_state_and_rel_position_and_id", order: { id: :desc }, using: :btree
t.index ["project_id", "updated_at", "id", "state"], name: "index_issues_on_project_id_and_updated_at_and_id_and_state", using: :btree
t.index ["relative_position"], name: "index_issues_on_relative_position", using: :btree
t.index ["state"], name: "index_issues_on_state", using: :btree