return status 0 for ErrNoChange #182

This commit is contained in:
Matthias Kadenbach 2017-03-12 12:33:13 -07:00
parent cecce18c51
commit c03b03c909
No known key found for this signature in database
GPG Key ID: DC1F4DC6D31A7031
1 changed files with 25 additions and 5 deletions

View File

@ -8,18 +8,30 @@ import (
func gotoCmd(m *migrate.Migrate, v uint) {
if err := m.Migrate(v); err != nil {
log.fatalErr(err)
if err != migrate.ErrNoChange {
log.fatalErr(err)
} else {
log.Println(err)
}
}
}
func upCmd(m *migrate.Migrate, limit int) {
if limit >= 0 {
if err := m.Steps(limit); err != nil {
log.fatalErr(err)
if err != migrate.ErrNoChange {
log.fatalErr(err)
} else {
log.Println(err)
}
}
} else {
if err := m.Up(); err != nil {
log.fatalErr(err)
if err != migrate.ErrNoChange {
log.fatalErr(err)
} else {
log.Println(err)
}
}
}
}
@ -27,11 +39,19 @@ func upCmd(m *migrate.Migrate, limit int) {
func downCmd(m *migrate.Migrate, limit int) {
if limit >= 0 {
if err := m.Steps(-limit); err != nil {
log.fatalErr(err)
if err != migrate.ErrNoChange {
log.fatalErr(err)
} else {
log.Println(err)
}
}
} else {
if err := m.Down(); err != nil {
log.fatalErr(err)
if err != migrate.ErrNoChange {
log.fatalErr(err)
} else {
log.Println(err)
}
}
}
}