From 1802cc8acaa13391da7ef3f36452fc63d0f90342 Mon Sep 17 00:00:00 2001 From: owensmallwood Date: Wed, 22 Jun 2022 17:35:33 -0600 Subject: [PATCH] Add correct table definition for migrations for old dashboard_public schema (#51292) Co-authored-by: Jesse Weaver --- .../migrations/dashboard_public_mig.go | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/pkg/services/sqlstore/migrations/dashboard_public_mig.go b/pkg/services/sqlstore/migrations/dashboard_public_mig.go index 22c8a42a4d7..b3722b621e7 100644 --- a/pkg/services/sqlstore/migrations/dashboard_public_mig.go +++ b/pkg/services/sqlstore/migrations/dashboard_public_mig.go @@ -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")