|
@@ -6,11 +6,11 @@ import . "github.com/torkelo/grafana-pro/pkg/services/sqlstore/migrator"
|
|
|
// 1. Never change a migration that is committed and pushed to master
|
|
// 1. Never change a migration that is committed and pushed to master
|
|
|
// 2. Always add new migrations (to change or undo previous migrations)
|
|
// 2. Always add new migrations (to change or undo previous migrations)
|
|
|
// 3. Some migraitons are not yet written (rename column, table, drop table, index etc)
|
|
// 3. Some migraitons are not yet written (rename column, table, drop table, index etc)
|
|
|
-// 4
|
|
|
|
|
|
|
|
|
|
func addMigrations(mg *Migrator) {
|
|
func addMigrations(mg *Migrator) {
|
|
|
addMigrationLogMigrations(mg)
|
|
addMigrationLogMigrations(mg)
|
|
|
addUserMigrations(mg)
|
|
addUserMigrations(mg)
|
|
|
|
|
+ addFavoritesMigrations(mg)
|
|
|
addAccountMigrations(mg)
|
|
addAccountMigrations(mg)
|
|
|
addDashboardMigration(mg)
|
|
addDashboardMigration(mg)
|
|
|
addDataSourceMigration(mg)
|
|
addDataSourceMigration(mg)
|
|
@@ -55,6 +55,18 @@ func addUserMigrations(mg *Migrator) {
|
|
|
Table("user").Column(&Column{Name: "rands", Type: DB_NVarchar, Length: 255, Nullable: true}))
|
|
Table("user").Column(&Column{Name: "rands", Type: DB_NVarchar, Length: 255, Nullable: true}))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func addFavoritesMigrations(mg *Migrator) {
|
|
|
|
|
+ mg.AddMigration("create favorite table", new(AddTableMigration).
|
|
|
|
|
+ Name("favorite").WithColumns(
|
|
|
|
|
+ &Column{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
|
|
|
|
|
+ &Column{Name: "user_id", Type: DB_BigInt, Nullable: false},
|
|
|
|
|
+ &Column{Name: "dashboard_id", Type: DB_BigInt, Nullable: false},
|
|
|
|
|
+ ))
|
|
|
|
|
+
|
|
|
|
|
+ mg.AddMigration("add unique index favorite.user_id_dashboard_id", new(AddIndexMigration).
|
|
|
|
|
+ Table("favorite").Columns("user_id", "dashboard_id").Unique())
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func addAccountMigrations(mg *Migrator) {
|
|
func addAccountMigrations(mg *Migrator) {
|
|
|
mg.AddMigration("create account table", new(AddTableMigration).
|
|
mg.AddMigration("create account table", new(AddTableMigration).
|
|
|
Name("account").WithColumns(
|
|
Name("account").WithColumns(
|