diff options
Diffstat (limited to 'db/post_migrate/20200127141953_add_temporary_snippet_notes_with_mentions_index.rb')
-rw-r--r-- | db/post_migrate/20200127141953_add_temporary_snippet_notes_with_mentions_index.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/db/post_migrate/20200127141953_add_temporary_snippet_notes_with_mentions_index.rb b/db/post_migrate/20200127141953_add_temporary_snippet_notes_with_mentions_index.rb new file mode 100644 index 00000000000..ec9b8b76f6f --- /dev/null +++ b/db/post_migrate/20200127141953_add_temporary_snippet_notes_with_mentions_index.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddTemporarySnippetNotesWithMentionsIndex < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'snippet_mentions_temp_index' + INDEX_CONDITION = "note LIKE '%@%'::text AND notes.noteable_type = 'Snippet'" + + disable_ddl_transaction! + + def up + # create temporary index for notes with mentions, may take well over 1h + add_concurrent_index(:notes, :id, where: INDEX_CONDITION, name: INDEX_NAME) + end + + def down + remove_concurrent_index(:notes, :id, where: INDEX_CONDITION, name: INDEX_NAME) + end +end |