Alerting: Fix migration pauses all alert rules on PostgreSQL (#63951)

This commit fixes a serious bug in Grafana 9.4.1 where on upgrade
a migration would pause all existing alert rules and change the
default value of the column to true.
pull/63972/head
George Robinson 2 years ago committed by GitHub
parent 5510fdc3ce
commit 030f6c948f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      pkg/services/sqlstore/migrations/ualert/tables.go

@ -290,6 +290,11 @@ func addAlertRuleMigrations(mg *migrator.Migrator, defaultIntervalSeconds int64)
Default: "0",
},
))
// This migration fixes a bug where "false" for the default value created a column with default "true" in PostgreSQL databases
mg.AddMigration("fix is_paused column for alert_rule table", migrator.NewRawSQLMigration("").
Postgres(`ALTER TABLE alert_rule ALTER COLUMN is_paused SET DEFAULT false;
UPDATE alert_rule SET is_paused = false;`))
}
func addAlertRuleVersionMigrations(mg *migrator.Migrator) {
@ -354,6 +359,11 @@ func addAlertRuleVersionMigrations(mg *migrator.Migrator) {
Default: "0",
},
))
// This migration fixes a bug where "false" for the default value created a column with default "true" in PostgreSQL databases
mg.AddMigration("fix is_paused column for alert_rule_version table", migrator.NewRawSQLMigration("").
Postgres(`ALTER TABLE alert_rule_version ALTER COLUMN is_paused SET DEFAULT false;
UPDATE alert_rule_version SET is_paused = false;`))
}
func addAlertmanagerConfigMigrations(mg *migrator.Migrator) {

Loading…
Cancel
Save