Alerting: Persist AlertInstance ResolvedAt & LastSentAt (#89135)

* Alerting: Persist AlertInstance ResolvedAt & LastSentAt

* Fix test

* Modify existing tests

* Fix merge conflicts from nullable LastSentAt & ResolvedAt
This commit is contained in:
Matthew Jacobson
2024-07-12 12:26:58 -04:00
committed by GitHub
parent e1f030592f
commit ba800692c6
10 changed files with 121 additions and 17 deletions
@@ -123,6 +123,8 @@ func (oss *OSSMigrations) AddMigration(mg *Migrator) {
accesscontrol.AddManagedFolderAlertingSilencesActionsMigrator(mg)
ualert.AddRecordingRuleColumns(mg)
ualert.AddStateResolvedAtColumns(mg)
}
func addStarMigrations(mg *Migrator) {
@@ -0,0 +1,18 @@
package ualert
import "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
// AddStateResolvedAtColumns adds columns to alert_instance to represent ResolvedAt and LastSentAt.
func AddStateResolvedAtColumns(mg *migrator.Migrator) {
mg.AddMigration("add resolved_at column to alert_instance table", migrator.NewAddColumnMigration(migrator.Table{Name: "alert_instance"}, &migrator.Column{
Name: "resolved_at",
Type: migrator.DB_BigInt, // BigInt, to match existing time fields.
Nullable: true,
}))
mg.AddMigration("add last_sent_at column to alert_instance table", migrator.NewAddColumnMigration(migrator.Table{Name: "alert_instance"}, &migrator.Column{
Name: "last_sent_at",
Type: migrator.DB_BigInt,
Nullable: true,
}))
}