Alerting: Create alertmanager config history table (#60103)

Create config history table
alexweav/config-history-rework
Alexander Weaver 3 years ago committed by GitHub
parent 435ada45c5
commit 3bdffc92cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      pkg/services/sqlstore/migrations/ualert/tables.go

@ -33,6 +33,8 @@ func AddTablesMigrations(mg *migrator.Migrator) {
AddProvisioningMigrations(mg)
AddAlertImageMigrations(mg)
AddAlertmanagerConfigHistoryMigrations(mg)
}
// AddAlertDefinitionMigrations should not be modified.
@ -345,6 +347,26 @@ func AddAlertmanagerConfigMigrations(mg *migrator.Migrator) {
}))
}
func AddAlertmanagerConfigHistoryMigrations(mg *migrator.Migrator) {
alertConfigHistory := migrator.Table{
Name: "alert_configuration_history",
Columns: []*migrator.Column{
{Name: "id", Type: migrator.DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
{Name: "org_id", Type: migrator.DB_BigInt, Nullable: false, Default: "0"},
{Name: "alertmanager_configuration", Type: migrator.DB_MediumText, Nullable: false},
{Name: "configuration_hash", Type: migrator.DB_Varchar, Nullable: false, Default: "'not-yet-calculated'", Length: 32},
{Name: "configuration_version", Type: migrator.DB_NVarchar, Length: 3}, // In a format of vXX e.g. v1, v2, v10, etc
{Name: "created_at", Type: migrator.DB_Int, Nullable: false},
{Name: "default", Type: migrator.DB_Bool, Nullable: false, Default: "0"},
},
Indices: []*migrator.Index{
{Cols: []string{"org_id"}},
},
}
mg.AddMigration("create_alert_configuration_history_table", migrator.NewAddTableMigration(alertConfigHistory))
}
func AddAlertAdminConfigMigrations(mg *migrator.Migrator) {
adminConfiguration := migrator.Table{
Name: "ngalert_configuration",

Loading…
Cancel
Save