summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-12 00:09:34 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-12 00:09:34 +0000
commit5781a4966047232d4725f9ee4769c4bd5aed9b26 (patch)
tree0ef2b81a40931ec51f8fdd5284ed9e47cf42a923 /db
parent4d48b3cfcd74bcca0f0f305746f74cf7224dd78b (diff)
downloadgitlab-ce-5781a4966047232d4725f9ee4769c4bd5aed9b26.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20200128132510_add_temporary_index_for_notes_with_mentions.rb29
-rw-r--r--db/schema.rb3
2 files changed, 30 insertions, 2 deletions
diff --git a/db/post_migrate/20200128132510_add_temporary_index_for_notes_with_mentions.rb b/db/post_migrate/20200128132510_add_temporary_index_for_notes_with_mentions.rb
new file mode 100644
index 00000000000..bd55485f871
--- /dev/null
+++ b/db/post_migrate/20200128132510_add_temporary_index_for_notes_with_mentions.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class AddTemporaryIndexForNotesWithMentions < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ INDEX_CONDITION = "note LIKE '%@%'::text"
+ INDEX_NAME = 'note_mentions_temp_index'
+
+ EPIC_MENTIONS_INDEX_NAME = 'epic_mentions_temp_index'
+ DESIGN_MENTIONS_INDEX_NAME = 'design_mentions_temp_index'
+
+ def up
+ # create temporary index for notes with mentions, may take well over 1h
+ add_concurrent_index(:notes, [:id, :noteable_type], where: INDEX_CONDITION, name: INDEX_NAME)
+
+ # cleanup previous temporary indexes, as we'll be usig the single one
+ remove_concurrent_index(:notes, :id, name: EPIC_MENTIONS_INDEX_NAME)
+ remove_concurrent_index(:notes, :id, name: DESIGN_MENTIONS_INDEX_NAME)
+ end
+
+ def down
+ remove_concurrent_index(:notes, :id, name: INDEX_NAME)
+
+ add_concurrent_index(:notes, :id, where: "#{INDEX_CONDITION} AND noteable_type='Epic'", name: EPIC_MENTIONS_INDEX_NAME)
+ add_concurrent_index(:notes, :id, where: "#{INDEX_CONDITION} AND noteable_type='DesignManagement::Design'", name: DESIGN_MENTIONS_INDEX_NAME)
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 2b726073035..3128317ec99 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -2840,8 +2840,7 @@ ActiveRecord::Schema.define(version: 2020_03_10_135823) do
t.index ["commit_id"], name: "index_notes_on_commit_id"
t.index ["created_at"], name: "index_notes_on_created_at"
t.index ["discussion_id"], name: "index_notes_on_discussion_id"
- t.index ["id"], name: "design_mentions_temp_index", where: "((note ~~ '%@%'::text) AND ((noteable_type)::text = 'DesignManagement::Design'::text))"
- t.index ["id"], name: "epic_mentions_temp_index", where: "((note ~~ '%@%'::text) AND ((noteable_type)::text = 'Epic'::text))"
+ t.index ["id", "noteable_type"], name: "note_mentions_temp_index", where: "(note ~~ '%@%'::text)"
t.index ["line_code"], name: "index_notes_on_line_code"
t.index ["note"], name: "index_notes_on_note_trigram", opclass: :gin_trgm_ops, using: :gin
t.index ["note"], name: "tmp_idx_on_promoted_notes", where: "(((noteable_type)::text = 'Issue'::text) AND (system IS TRUE) AND (note ~~ 'promoted to epic%'::text))"