diff --git a/gorm.go b/gorm.go index a484b002..f11fb9e1 100644 --- a/gorm.go +++ b/gorm.go @@ -114,7 +114,9 @@ func Open(dialector Dialector, opts ...Option) (db *DB, err error) { if err := opt.Apply(config); err != nil { return nil, err } - defer opt.AfterInitialize(db) + defer func() { + opt.AfterInitialize(db) + }() } }