Currently the https://godoc.org/github.com/rubenv/sql-migrate#Migration has the Up, Down []string which I guess will be read and run by migrate.Exec.
It would be nice if the Migration is an interface then we can do some update that need more than SQL script. For example:
type ComplexPwdGenMigration {
DB
}
func (m *ComplexMigration) Up() []string {
// then something like:
// people := m.DB.GetAll()
// for each person in fo person.password = veryComplexPasswordGenerate(person.id) + m.DB.Save(person)
return nil
}
// and implement the rest method of
migrations := &MixMigrationSource{
Migrations: []Migrator{
&migrate.Migration{
Id: "123",
Up: []string{"CREATE TABLE people (id int, password var)"},
Down: []string{"DROP TABLE people"},
},
&ComplexPwdGenMigration,
&AnotherComplexProcessMigration,
&migrate.Migration{
Id: "123",
Up: []string{"...."},
Down: []string{"....."},
},
},
}
Currently the https://godoc.org/github.com/rubenv/sql-migrate#Migration has the Up, Down []string which I guess will be read and run by migrate.Exec. It would be nice if the Migration is an interface then we can do some update that need more than SQL script. For example: