Commit d61cc087 authored by Sean Arnold's avatar Sean Arnold

Use new index name and create before removing

parent 6584ba00
......@@ -5,17 +5,18 @@ class AdjustUniqueIndexAlertManagementAlerts < ActiveRecord::Migration[6.0]
DOWNTIME = false
INDEX_NAME = 'index_alert_management_alerts_on_project_id_and_fingerprint'
NEW_INDEX_NAME = 'index_partial_am_alerts_on_project_id_and_fingerprint'
RESOLVED_STATUS = 2
# rubocop:disable Migration/RemoveIndex
# rubocop:disable Migration/AddIndex
def up
add_index(:alert_management_alerts, %w(project_id fingerprint), where: "status <> '#{RESOLVED_STATUS}'", name: NEW_INDEX_NAME, unique: true, using: :btree)
remove_index :alert_management_alerts, name: INDEX_NAME
add_index(:alert_management_alerts, %w(project_id fingerprint), where: "status <> '#{RESOLVED_STATUS}'", name: INDEX_NAME, unique: true, using: :btree)
end
def down
remove_index :alert_management_alerts, name: INDEX_NAME
remove_index :alert_management_alerts, name: NEW_INDEX_NAME
add_index(:alert_management_alerts, %w(project_id fingerprint), name: INDEX_NAME, unique: true, using: :btree)
end
# rubocop:enable Migration/RemoveIndex
......
......@@ -18695,8 +18695,6 @@ CREATE INDEX index_alert_management_alerts_on_environment_id ON public.alert_man
CREATE INDEX index_alert_management_alerts_on_issue_id ON public.alert_management_alerts USING btree (issue_id);
CREATE UNIQUE INDEX index_alert_management_alerts_on_project_id_and_fingerprint ON public.alert_management_alerts USING btree (project_id, fingerprint) WHERE (status <> '2'::smallint);
CREATE UNIQUE INDEX index_alert_management_alerts_on_project_id_and_iid ON public.alert_management_alerts USING btree (project_id, iid);
CREATE INDEX index_alert_management_alerts_on_prometheus_alert_id ON public.alert_management_alerts USING btree (prometheus_alert_id) WHERE (prometheus_alert_id IS NOT NULL);
......@@ -19945,6 +19943,8 @@ CREATE INDEX index_pages_domains_on_verified_at_and_enabled_until ON public.page
CREATE INDEX index_pages_domains_on_wildcard ON public.pages_domains USING btree (wildcard);
CREATE UNIQUE INDEX index_partial_am_alerts_on_project_id_and_fingerprint ON public.alert_management_alerts USING btree (project_id, fingerprint) WHERE (status <> '2'::smallint);
CREATE UNIQUE INDEX index_partitioned_foreign_keys_unique_index ON public.partitioned_foreign_keys USING btree (to_table, from_table, from_column);
CREATE INDEX index_pat_on_user_id_and_expires_at ON public.personal_access_tokens USING btree (user_id, expires_at);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment