Просмотр исходного кода

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
Marcus Efraimsson 8 лет назад
Родитель
Сommit
c1cff3849e
1 измененных файлов с 4 добавлено и 5 удалено
  1. 4 5
      pkg/services/sqlstore/migrations/dashboard_mig.go

+ 4 - 5
pkg/services/sqlstore/migrations/dashboard_mig.go

@@ -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,
 	}))
 }