Progress on database schema migration for account -> org refactor

This commit is contained in:
Torkel Ödegaard
2015-02-24 11:46:34 +01:00
parent da41d99aa7
commit 02a89c752b
16 changed files with 595 additions and 193 deletions

View File

@@ -118,6 +118,17 @@ func (mg *Migrator) exec(m Migration) error {
}
err := mg.inTransaction(func(sess *xorm.Session) error {
condition := m.GetCondition()
if condition != nil {
sql, args := condition.Sql(mg.dialect)
results, err := sess.Query(sql, args...)
if err != nil || len(results) == 0 {
log.Info("Migrator: skipping migration id: %v, condition not fulfilled", m.Id())
return nil
}
}
_, err := sess.Exec(m.Sql(mg.dialect))
if err != nil {
log.Error(3, "Migrator: exec FAILED migration id: %v, err: %v", m.Id(), err)