mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(query_part): refactoring query part
This commit is contained in:
@@ -20,28 +20,30 @@ func addAlertMigrations(mg *Migrator) {
|
||||
{Name: "frequency", Type: DB_BigInt, Nullable: false},
|
||||
{Name: "handler", Type: DB_BigInt, Nullable: false},
|
||||
{Name: "severity", Type: DB_Text, Nullable: false},
|
||||
{Name: "enabled", Type: DB_Bool, Nullable: false},
|
||||
{Name: "paused", Type: DB_Bool, Nullable: false},
|
||||
{Name: "silenced", Type: DB_Bool, Nullable: false},
|
||||
{Name: "execution_error", Type: DB_Text, Nullable: false},
|
||||
{Name: "last_eval_data", Type: DB_Text, Nullable: false},
|
||||
{Name: "last_eval_time", Type: DB_DateTime, Nullable: false},
|
||||
{Name: "created", Type: DB_DateTime, Nullable: false},
|
||||
{Name: "updated", Type: DB_DateTime, Nullable: false},
|
||||
{Name: "updated_by", Type: DB_BigInt, Nullable: false},
|
||||
{Name: "created_by", Type: DB_BigInt, Nullable: false},
|
||||
},
|
||||
Indices: []*Index{
|
||||
{Cols: []string{"org_id", "id"}, Type: IndexType},
|
||||
{Cols: []string{"state"}, Type: IndexType},
|
||||
{Cols: []string{"dashboard_id"}, Type: IndexType},
|
||||
},
|
||||
}
|
||||
|
||||
// create table
|
||||
mg.AddMigration("create alert table v1", NewAddTableMigration(alertV1))
|
||||
|
||||
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))
|
||||
// create indices
|
||||
mg.AddMigration("add index alert org_id & id ", NewAddIndexMigration(alertV1, alertV1.Indices[0]))
|
||||
mg.AddMigration("add index alert state", NewAddIndexMigration(alertV1, alertV1.Indices[1]))
|
||||
mg.AddMigration("add index alert dashboard_id", NewAddIndexMigration(alertV1, alertV1.Indices[2]))
|
||||
|
||||
alert_notification := Table{
|
||||
Name: "alert_notification",
|
||||
@@ -54,7 +56,11 @@ func addAlertMigrations(mg *Migrator) {
|
||||
{Name: "created", Type: DB_DateTime, Nullable: false},
|
||||
{Name: "updated", Type: DB_DateTime, Nullable: false},
|
||||
},
|
||||
Indices: []*Index{
|
||||
{Cols: []string{"org_id", "name"}, Type: UniqueIndex},
|
||||
},
|
||||
}
|
||||
|
||||
mg.AddMigration("create alert_notification table v1", NewAddTableMigration(alert_notification))
|
||||
mg.AddMigration("add index alert_notification org_id & name", NewAddIndexMigration(alert_notification, alert_notification.Indices[0]))
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ func addAnnotationMig(mg *Migrator) {
|
||||
{Name: "org_id", Type: DB_BigInt, Nullable: false},
|
||||
{Name: "alert_id", Type: DB_BigInt, Nullable: true},
|
||||
{Name: "user_id", Type: DB_BigInt, Nullable: true},
|
||||
{Name: "panel_link_id", Type: DB_NVarchar, Length: 32, Nullable: false},
|
||||
{Name: "type", Type: DB_NVarchar, Length: 25, Nullable: false},
|
||||
{Name: "title", Type: DB_Text, Nullable: false},
|
||||
{Name: "text", Type: DB_Text, Nullable: false},
|
||||
@@ -25,7 +24,6 @@ func addAnnotationMig(mg *Migrator) {
|
||||
Indices: []*Index{
|
||||
{Cols: []string{"org_id", "alert_id"}, Type: IndexType},
|
||||
{Cols: []string{"org_id", "type"}, Type: IndexType},
|
||||
{Cols: []string{"org_id", "panel_link_id"}, Type: IndexType},
|
||||
{Cols: []string{"timestamp"}, Type: IndexType},
|
||||
},
|
||||
}
|
||||
@@ -35,6 +33,5 @@ func addAnnotationMig(mg *Migrator) {
|
||||
// create indices
|
||||
mg.AddMigration("add index annotation org_id & alert_id ", NewAddIndexMigration(table, table.Indices[0]))
|
||||
mg.AddMigration("add index annotation org_id & type", NewAddIndexMigration(table, table.Indices[1]))
|
||||
mg.AddMigration("add index annotation org_id & panel_link_id ", NewAddIndexMigration(table, table.Indices[2]))
|
||||
mg.AddMigration("add index annotation timestamp", NewAddIndexMigration(table, table.Indices[3]))
|
||||
mg.AddMigration("add index annotation timestamp", NewAddIndexMigration(table, table.Indices[2]))
|
||||
}
|
||||
|
||||
16
pkg/services/sqlstore/migrations/heartbeat_mig.go
Normal file
16
pkg/services/sqlstore/migrations/heartbeat_mig.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package migrations
|
||||
|
||||
//
|
||||
// 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))
|
||||
//
|
||||
//
|
||||
Reference in New Issue
Block a user