Commit 50aa9ec6 by Marcus Efraimsson

db: add migrations for generating uid for existing dashboards. #7883

parent 401b01e1
......@@ -155,4 +155,9 @@ func addDashboardMigration(mg *Migrator) {
mg.AddMigration("Add column uid in dashboard", NewAddColumnMigration(dashboardV2, &Column{
Name: "uid", Type: DB_NVarchar, Length: 12, Nullable: true,
}))
mg.AddMigration("Set uid column values", new(RawSqlMigration).
Sqlite("UPDATE dashboard SET uid=printf('%09d',id) WHERE uid IS NULL;").
Postgres("UPDATE dashboard SET uid=lpad('' || id,9,'0') WHERE uid IS NULL;").
Mysql("UPDATE dashboard SET uid=lpad(id,9,'0') WHERE uid IS NULL;"))
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment