Add hooks after completion of Migrate Value

This commit is contained in:
kain 2020-11-17 00:06:11 +08:00
parent a8db54afd6
commit 298b3ac523
2 changed files with 8 additions and 0 deletions

View File

@ -33,6 +33,7 @@ type ColumnType interface {
type Migrator interface {
// AutoMigrate
AutoMigrate(dst ...interface{}) error
After(dst interface{}) error
// Database
CurrentDatabase() string

View File

@ -147,11 +147,18 @@ func (m Migrator) AutoMigrate(values ...interface{}) error {
return err
}
}
if err := tx.Migrator().After(value); err != nil {
return err
}
}
return nil
}
func (m Migrator) After(dst interface{}) error {
return nil
}
func (m Migrator) CreateTable(values ...interface{}) error {
for _, value := range m.ReorderModels(values, false) {
tx := m.DB.Session(&gorm.Session{})