pre migration
This commit is contained in:
1 parent
3e9ac30812
commit
70efb513dd
2 files changed
+14
No files matched your search
@@ -14,3 +14,8 @@ type EntitiesProvider interface {
|
|||||||
maf.Module
|
maf.Module
|
||||||
GetDBEntities() []interface{}
|
GetDBEntities() []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PreMigrationConsumer interface {
|
||||||
|
Consumer
|
||||||
|
DBPreMigration(db *gorm.DB) error
|
||||||
|
}
|
||||||
@@ -110,6 +110,15 @@ func (m *Module) autoMigrate() error {
|
|||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
for _, module := range m.manager.GetModulesList() {
|
||||||
|
if preMigrationModule, ok := module.(PreMigrationConsumer); ok {
|
||||||
|
err = preMigrationModule.DBPreMigration(m.db)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
err = m.autoMigrateTables()
|
err = m.autoMigrateTables()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in new issue
Block a user