|
|
@@ -18,25 +18,34 @@ func AddMigrations(mg *Migrator) {
|
|
|
}
|
|
|
|
|
|
func addMigrationLogMigrations(mg *Migrator) {
|
|
|
- mg.AddMigration("create migration_log table", new(AddTableMigration).
|
|
|
- Name("migration_log").WithColumns(
|
|
|
- &Column{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
|
|
|
- &Column{Name: "migration_id", Type: DB_NVarchar, Length: 255},
|
|
|
- &Column{Name: "sql", Type: DB_Text},
|
|
|
- &Column{Name: "success", Type: DB_Bool},
|
|
|
- &Column{Name: "error", Type: DB_Text},
|
|
|
- &Column{Name: "timestamp", Type: DB_DateTime},
|
|
|
- ))
|
|
|
+ migrationLogV1 := Table{
|
|
|
+ Name: "migration_log",
|
|
|
+ Columns: []*Column{
|
|
|
+ &Column{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
|
|
|
+ &Column{Name: "migration_id", Type: DB_NVarchar, Length: 255},
|
|
|
+ &Column{Name: "sql", Type: DB_Text},
|
|
|
+ &Column{Name: "success", Type: DB_Bool},
|
|
|
+ &Column{Name: "error", Type: DB_Text},
|
|
|
+ &Column{Name: "timestamp", Type: DB_DateTime},
|
|
|
+ },
|
|
|
+ }
|
|
|
+
|
|
|
+ mg.AddMigration("create migration_log table", NewAddTableMigration(migrationLogV1))
|
|
|
}
|
|
|
|
|
|
func addStarMigrations(mg *Migrator) {
|
|
|
- mg.AddMigration("create star table", new(AddTableMigration).
|
|
|
- Name("star").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},
|
|
|
- ))
|
|
|
+ starV1 := Table{
|
|
|
+ Name: "star",
|
|
|
+ Columns: []*Column{
|
|
|
+ &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},
|
|
|
+ },
|
|
|
+ Indices: []*Index{
|
|
|
+ &Index{Cols: []string{"user_id", "dashboard_id"}, Type: UniqueIndex},
|
|
|
+ },
|
|
|
+ }
|
|
|
|
|
|
- mg.AddMigration("add unique index star.user_id_dashboard_id", new(AddIndexMigration).
|
|
|
- Table("star").Columns("user_id", "dashboard_id").Unique())
|
|
|
+ mg.AddMigration("create star table", NewAddTableMigration(starV1))
|
|
|
+ mg.AddMigration("add unique index star.user_id_dashboard_id", NewAddIndexMigration(starV1, starV1.Indices[0]))
|
|
|
}
|