diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 07:33:21 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 07:33:21 +0000 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /db/post_migrate/20220505174658_update_index_on_alerts_to_exclude_null_fingerprints.rb | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) | |
download | gitlab-ce-36a59d088eca61b834191dacea009677a96c052f.tar.gz |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'db/post_migrate/20220505174658_update_index_on_alerts_to_exclude_null_fingerprints.rb')
-rw-r--r-- | db/post_migrate/20220505174658_update_index_on_alerts_to_exclude_null_fingerprints.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/db/post_migrate/20220505174658_update_index_on_alerts_to_exclude_null_fingerprints.rb b/db/post_migrate/20220505174658_update_index_on_alerts_to_exclude_null_fingerprints.rb new file mode 100644 index 00000000000..5cffdb641d6 --- /dev/null +++ b/db/post_migrate/20220505174658_update_index_on_alerts_to_exclude_null_fingerprints.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class UpdateIndexOnAlertsToExcludeNullFingerprints < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + OLD_INDEX_NAME = 'index_partial_am_alerts_on_project_id_and_fingerprint' + NEW_INDEX_NAME = 'index_unresolved_alerts_on_project_id_and_fingerprint' + + def up + add_concurrent_index :alert_management_alerts, + [:project_id, :fingerprint], + where: "fingerprint IS NOT NULL and status <> 2", + name: NEW_INDEX_NAME, + unique: true + + remove_concurrent_index_by_name :alert_management_alerts, OLD_INDEX_NAME + end + + def down + add_concurrent_index :alert_management_alerts, + [:project_id, :fingerprint], + where: "status <> 2", + name: OLD_INDEX_NAME, + unique: true + + remove_concurrent_index_by_name :alert_management_alerts, NEW_INDEX_NAME + end +end |