2016-04-13 10:33:45 +02:00
|
|
|
package migrations
|
|
|
|
|
|
2016-05-23 07:47:38 +02:00
|
|
|
import (
|
|
|
|
|
. "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
|
|
|
|
|
)
|
2016-04-13 10:33:45 +02:00
|
|
|
|
|
|
|
|
func addAlertMigrations(mg *Migrator) {
|
2016-05-23 10:02:17 +02:00
|
|
|
|
2016-04-13 10:33:45 +02:00
|
|
|
alertV1 := Table{
|
2016-06-11 10:54:24 +02:00
|
|
|
Name: "alert",
|
2016-04-13 10:33:45 +02:00
|
|
|
Columns: []*Column{
|
|
|
|
|
{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
|
|
|
|
|
{Name: "dashboard_id", Type: DB_BigInt, Nullable: false},
|
|
|
|
|
{Name: "panel_id", Type: DB_BigInt, Nullable: false},
|
2016-04-25 16:18:28 +02:00
|
|
|
{Name: "org_id", Type: DB_BigInt, Nullable: false},
|
2016-06-06 17:11:46 +02:00
|
|
|
{Name: "name", Type: DB_NVarchar, Length: 255, Nullable: false},
|
2016-04-13 10:33:45 +02:00
|
|
|
{Name: "description", Type: DB_NVarchar, Length: 255, Nullable: false},
|
2016-04-28 08:23:50 +02:00
|
|
|
{Name: "state", Type: DB_NVarchar, Length: 255, Nullable: false},
|
2016-06-13 15:18:19 +02:00
|
|
|
{Name: "settings", Type: DB_Text, Nullable: false},
|
2016-06-13 15:58:22 +02:00
|
|
|
{Name: "handler", Type: DB_BigInt, Nullable: false},
|
2016-06-11 10:13:33 +02:00
|
|
|
{Name: "enabled", Type: DB_Bool, Nullable: false},
|
2016-05-20 14:23:24 +02:00
|
|
|
{Name: "created", Type: DB_DateTime, Nullable: false},
|
|
|
|
|
{Name: "updated", Type: DB_DateTime, Nullable: false},
|
2016-04-13 10:33:45 +02:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// create table
|
2016-06-11 10:54:24 +02:00
|
|
|
mg.AddMigration("create alert table v1", NewAddTableMigration(alertV1))
|
2016-04-25 14:28:18 +02:00
|
|
|
|
|
|
|
|
alert_changes := Table{
|
2016-06-11 10:54:24 +02:00
|
|
|
Name: "alert_change",
|
2016-04-25 14:28:18 +02:00
|
|
|
Columns: []*Column{
|
|
|
|
|
{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
|
|
|
|
|
{Name: "alert_id", Type: DB_BigInt, Nullable: false},
|
|
|
|
|
{Name: "org_id", Type: DB_BigInt, Nullable: false},
|
2016-04-25 16:18:28 +02:00
|
|
|
{Name: "type", Type: DB_NVarchar, Length: 50, Nullable: false},
|
2016-04-25 14:28:18 +02:00
|
|
|
{Name: "created", Type: DB_DateTime, Nullable: false},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-11 10:54:24 +02:00
|
|
|
mg.AddMigration("create alert_change table v1", NewAddTableMigration(alert_changes))
|
2016-04-28 10:59:46 +02:00
|
|
|
|
|
|
|
|
alert_state_log := Table{
|
2016-05-04 14:58:00 +02:00
|
|
|
Name: "alert_state",
|
2016-04-28 10:59:46 +02:00
|
|
|
Columns: []*Column{
|
|
|
|
|
{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
|
|
|
|
|
{Name: "alert_id", Type: DB_BigInt, Nullable: false},
|
|
|
|
|
{Name: "org_id", Type: DB_BigInt, Nullable: false},
|
|
|
|
|
{Name: "new_state", Type: DB_NVarchar, Length: 50, Nullable: false},
|
|
|
|
|
{Name: "info", Type: DB_Text, Nullable: true},
|
|
|
|
|
{Name: "created", Type: DB_DateTime, Nullable: false},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mg.AddMigration("create alert_state_log table v1", NewAddTableMigration(alert_state_log))
|
2016-05-23 10:02:17 +02:00
|
|
|
|
|
|
|
|
alert_heartbeat := Table{
|
|
|
|
|
Name: "alert_heartbeat",
|
|
|
|
|
Columns: []*Column{
|
|
|
|
|
{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
|
|
|
|
|
{Name: "server_id", Type: DB_NVarchar, Length: 50, Nullable: false},
|
|
|
|
|
{Name: "created", Type: DB_DateTime, Nullable: false},
|
|
|
|
|
{Name: "updated", Type: DB_DateTime, Nullable: false},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mg.AddMigration("create alert_heartbeat table v1", NewAddTableMigration(alert_heartbeat))
|
2016-04-13 10:33:45 +02:00
|
|
|
}
|