summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2018-03-08 12:54:57 +0000
committerIan Baum <ibaum@gitlab.com>2018-03-15 13:13:27 -0500
commitbf95d272e7221140cdf0ee36dae8f2c5ed350b35 (patch)
tree77cc7305c1bcbaf2b251ac63fd8c9d09e26abf9c
parent3641b68686fb57927bf1db93360356f02090231f (diff)
downloadgitlab-ce-bf95d272e7221140cdf0ee36dae8f2c5ed350b35.tar.gz
Merge branch 'sh-add-missing-acts-as-taggable-indices' into 'master'
Adding missing indexes migrations from taggings table Closes #43927 See merge request gitlab-org/gitlab-ce!17563
-rw-r--r--changelogs/unreleased/sh-add-missing-acts-as-taggable-indices.yml5
-rw-r--r--db/migrate/20180306134842_add_missing_indexes_acts_as_taggable_on_engine.rb21
-rw-r--r--db/schema.rb2
3 files changed, 28 insertions, 0 deletions
diff --git a/changelogs/unreleased/sh-add-missing-acts-as-taggable-indices.yml b/changelogs/unreleased/sh-add-missing-acts-as-taggable-indices.yml
new file mode 100644
index 00000000000..d9a1a0db9e8
--- /dev/null
+++ b/changelogs/unreleased/sh-add-missing-acts-as-taggable-indices.yml
@@ -0,0 +1,5 @@
+---
+title: Adding missing indexes on taggings table
+merge_request:
+author:
+type: performance
diff --git a/db/migrate/20180306134842_add_missing_indexes_acts_as_taggable_on_engine.rb b/db/migrate/20180306134842_add_missing_indexes_acts_as_taggable_on_engine.rb
new file mode 100644
index 00000000000..06e402adcd7
--- /dev/null
+++ b/db/migrate/20180306134842_add_missing_indexes_acts_as_taggable_on_engine.rb
@@ -0,0 +1,21 @@
+# This migration comes from acts_as_taggable_on_engine (originally 6)
+#
+# It has been modified to handle no-downtime GitLab migrations. Several
+# indexes have been removed since they are not needed for GitLab.
+class AddMissingIndexesActsAsTaggableOnEngine < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :taggings, :tag_id unless index_exists? :taggings, :tag_id
+ add_concurrent_index :taggings, [:taggable_id, :taggable_type] unless index_exists? :taggings, [:taggable_id, :taggable_type]
+ end
+
+ def down
+ remove_concurrent_index :taggings, :tag_id
+ remove_concurrent_index :taggings, [:taggable_id, :taggable_type]
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index ee3fe52b0be..0301e6e4e4d 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -1701,7 +1701,9 @@ ActiveRecord::Schema.define(version: 20180308052825) do
end
add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true, using: :btree
+ add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id", using: :btree
add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree
+ add_index "taggings", ["taggable_id", "taggable_type"], name: "index_taggings_on_taggable_id_and_taggable_type", using: :btree
create_table "tags", force: :cascade do |t|
t.string "name"