diff --git a/changelogs/unreleased/296756-cablett-remove-index.yml b/changelogs/unreleased/296756-cablett-remove-index.yml new file mode 100644 index 0000000000000000000000000000000000000000..a0d19eb24bdf37eb71626ec4409c10e1e5c43819 --- /dev/null +++ b/changelogs/unreleased/296756-cablett-remove-index.yml @@ -0,0 +1,5 @@ +--- +title: Remove inconsistent index in backup_labels table +merge_request: 53189 +author: +type: other diff --git a/db/migrate/20210203002331_drop_backup_label_index.rb b/db/migrate/20210203002331_drop_backup_label_index.rb new file mode 100644 index 0000000000000000000000000000000000000000..430d2d0fb79609e16aab92800b5e7bf345d63662 --- /dev/null +++ b/db/migrate/20210203002331_drop_backup_label_index.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class DropBackupLabelIndex < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + INDEX_NAME = 'backup_labels_project_id_title_idx' + + def up + remove_concurrent_index_by_name(:backup_labels, name: INDEX_NAME) + end + + def down + add_concurrent_index :backup_labels, [:project_id, :title], name: INDEX_NAME, unique: true, where: 'group_id = NULL::integer' + end +end diff --git a/db/schema_migrations/20210203002331 b/db/schema_migrations/20210203002331 new file mode 100644 index 0000000000000000000000000000000000000000..f1ed6bf23f685fa6dd765159d20411570121d008 --- /dev/null +++ b/db/schema_migrations/20210203002331 @@ -0,0 +1 @@ +b8a19b2ebf648a1b79a488a7a2847f6a392e594464c1ba0ae96f274f583559e3 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 017ef14931f4246a8e1521bdf6f9ea11917ab30c..16abc7379755148848f0936b5803a7db1cfc6dd1 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -21025,8 +21025,6 @@ CREATE INDEX backup_labels_group_id_title_idx ON backup_labels USING btree (grou CREATE INDEX backup_labels_project_id_idx ON backup_labels USING btree (project_id); -CREATE UNIQUE INDEX backup_labels_project_id_title_idx ON backup_labels USING btree (project_id, title) WHERE (group_id = NULL::integer); - CREATE INDEX backup_labels_template_idx ON backup_labels USING btree (template) WHERE template; CREATE INDEX backup_labels_title_idx ON backup_labels USING btree (title);