From 294625759c63af2ea412369a13b8f4d3c76b4433 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 5 Mar 2021 14:12:55 +0800 Subject: [PATCH] Fix after initialize db callback --- gorm.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) + }() } }