diff options
Diffstat (limited to 'db/post_migrate/20220613095911_create_confidential_notes_index_on_id.rb')
-rw-r--r-- | db/post_migrate/20220613095911_create_confidential_notes_index_on_id.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/db/post_migrate/20220613095911_create_confidential_notes_index_on_id.rb b/db/post_migrate/20220613095911_create_confidential_notes_index_on_id.rb new file mode 100644 index 00000000000..80c26c3ea8a --- /dev/null +++ b/db/post_migrate/20220613095911_create_confidential_notes_index_on_id.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class CreateConfidentialNotesIndexOnId < Gitlab::Database::Migration[2.0] + OLD_INDEX_NAME = 'index_notes_on_confidential' + INDEX_NAME = 'index_notes_on_id_where_confidential' + + disable_ddl_transaction! + + def up + remove_concurrent_index_by_name :notes, name: OLD_INDEX_NAME + add_concurrent_index :notes, :id, where: 'confidential = true', name: INDEX_NAME + end + + def down + # we don't have to re-create OLD_INDEX_NAME index + # because it wasn't used yet, also its creation might be expensive + remove_concurrent_index_by_name :notes, name: INDEX_NAME + end +end |