mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
dashboard: change unique index for uid to include org_id
Make the max length of uid longer in case we want to change it later #7883
This commit is contained in:
parent
46e1296700
commit
c1cff3849e
@ -151,17 +151,16 @@ func addDashboardMigration(mg *Migrator) {
|
||||
Name: "has_acl", Type: DB_Bool, Nullable: false, Default: "0",
|
||||
}))
|
||||
|
||||
// new uid column
|
||||
mg.AddMigration("Add column uid in dashboard", NewAddColumnMigration(dashboardV2, &Column{
|
||||
Name: "uid", Type: DB_NVarchar, Length: 12, Nullable: true,
|
||||
Name: "uid", Type: DB_NVarchar, Length: 40, Nullable: true,
|
||||
}))
|
||||
|
||||
mg.AddMigration("Set uid column values", new(RawSqlMigration).
|
||||
mg.AddMigration("Update uid column values in dashboard", 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;"))
|
||||
|
||||
mg.AddMigration("Add index for uid in dashboard", NewAddIndexMigration(dashboardV2, &Index{
|
||||
Cols: []string{"uid"}, Type: UniqueIndex,
|
||||
mg.AddMigration("Add unique index dashboard_org_id_uid", NewAddIndexMigration(dashboardV2, &Index{
|
||||
Cols: []string{"org_id", "uid"}, Type: UniqueIndex,
|
||||
}))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user