mirror of
https://github.com/retailcrm/mg-bot-helper.git
synced 2025-04-20 01:10:58 +00:00
migrations fix
This commit is contained in:
parent
c2efcc6f10
commit
17c2dfa1e7
2 changed files with 7 additions and 7 deletions
|
@ -1,8 +1,6 @@
|
|||
package migrations
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/retailcrm/mg-transport-core/core"
|
||||
"gopkg.in/gormigrate.v1"
|
||||
|
@ -13,13 +11,17 @@ func init() {
|
|||
ID: "1577785798",
|
||||
Migrate: func(db *gorm.DB) error {
|
||||
if db.HasTable("schema_migrations") {
|
||||
return db.DropTable("schema_migrations").Error
|
||||
return db.Exec("ALTER TABLE schema_migrations RENAME TO schema_migrations_old;").Error
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
Rollback: func(db *gorm.DB) error {
|
||||
return errors.New("this migration cannot be rolled back")
|
||||
if db.HasTable("schema_migrations_old") {
|
||||
return db.Exec("ALTER TABLE schema_migrations_old RENAME TO schema_migrations;").Error
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package migrations
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/retailcrm/mg-bot-helper/src/models"
|
||||
"github.com/retailcrm/mg-transport-core/core"
|
||||
|
@ -16,7 +14,7 @@ func init() {
|
|||
return db.AutoMigrate(models.Connection{}).Error
|
||||
},
|
||||
Rollback: func(db *gorm.DB) error {
|
||||
return errors.New("this migration cannot be rolled back")
|
||||
return nil
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue