Add correct table definition for migrations for old dashboard_public schema (#51292)

Co-authored-by: Jesse Weaver <jesse.weaver@grafana.com>
This commit is contained in:
owensmallwood 2022-06-22 17:35:33 -06:00 committed by GitHub
parent d076bedb5e
commit 1802cc8aca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,22 @@ import (
func addPublicDashboardMigration(mg *Migrator) {
var dashboardPublicCfgV1 = Table{
Name: "dashboard_public_config",
Columns: []*Column{
{Name: "uid", Type: DB_NVarchar, Length: 40, IsPrimaryKey: true},
{Name: "dashboard_uid", Type: DB_NVarchar, Length: 40, Nullable: false},
{Name: "org_id", Type: DB_BigInt, Nullable: false},
{Name: "time_settings", Type: DB_Text, Nullable: false},
{Name: "refresh_rate", Type: DB_Int, Nullable: false, Default: "30"},
{Name: "template_variables", Type: DB_MediumText, Nullable: true},
},
Indices: []*Index{
{Cols: []string{"uid"}, Type: UniqueIndex},
{Cols: []string{"org_id", "dashboard_uid"}},
},
}
var dashboardPublicCfgV2 = Table{
Name: "dashboard_public_config",
Columns: []*Column{
{Name: "uid", Type: DB_NVarchar, Length: 40, IsPrimaryKey: true},
@ -44,8 +60,8 @@ func addPublicDashboardMigration(mg *Migrator) {
// recreate table - schema finalized for public dashboards v1
addDropAllIndicesMigrations(mg, "v2", dashboardPublicCfgV1)
mg.AddMigration("Drop public config table", NewDropTableMigration("dashboard_public_config"))
mg.AddMigration("Recreate dashboard public config v2", NewAddTableMigration(dashboardPublicCfgV1))
addTableIndicesMigrations(mg, "v2", dashboardPublicCfgV1)
mg.AddMigration("Recreate dashboard public config v2", NewAddTableMigration(dashboardPublicCfgV2))
addTableIndicesMigrations(mg, "v2", dashboardPublicCfgV2)
// rename table
addTableRenameMigration(mg, "dashboard_public_config", "dashboard_public", "v2")