From 7fcb6ecb912729767bcaf3c9531b98f0df33a18a Mon Sep 17 00:00:00 2001 From: Kyle Brandt Date: Fri, 2 Apr 2021 12:31:03 -0400 Subject: [PATCH] Alerting: Fix persistance migration (#32650) --- pkg/services/ngalert/store/database_mig.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/services/ngalert/store/database_mig.go b/pkg/services/ngalert/store/database_mig.go index dc8f08d4099..d1e418b969c 100644 --- a/pkg/services/ngalert/store/database_mig.go +++ b/pkg/services/ngalert/store/database_mig.go @@ -94,7 +94,6 @@ func AlertInstanceMigration(mg *migrator.Migrator) { {Name: "labels_hash", Type: migrator.DB_NVarchar, Length: 190, Nullable: false}, {Name: "current_state", Type: migrator.DB_NVarchar, Length: 190, Nullable: false}, {Name: "current_state_since", Type: migrator.DB_BigInt, Nullable: false}, - {Name: "current_state_end", Type: migrator.DB_BigInt, Nullable: false}, {Name: "last_eval_time", Type: migrator.DB_BigInt, Nullable: false}, }, PrimaryKeys: []string{"def_org_id", "def_uid", "labels_hash"}, @@ -108,6 +107,9 @@ func AlertInstanceMigration(mg *migrator.Migrator) { mg.AddMigration("create alert_instance table", migrator.NewAddTableMigration(alertInstance)) mg.AddMigration("add index in alert_instance table on def_org_id, def_uid and current_state columns", migrator.NewAddIndexMigration(alertInstance, alertInstance.Indices[0])) mg.AddMigration("add index in alert_instance table on def_org_id, current_state columns", migrator.NewAddIndexMigration(alertInstance, alertInstance.Indices[1])) + mg.AddMigration("add column current_state_end to alert_instance", migrator.NewAddColumnMigration(alertInstance, &migrator.Column{ + Name: "current_state_end", Type: migrator.DB_BigInt, Nullable: false, Default: "0", + })) } func AddAlertRuleMigrations(mg *migrator.Migrator, defaultIntervalSeconds int64) {