Store the *database.Database wrapper instead of calling .DB() eagerly at construction time. The GORM *gorm.DB is only available after the database's OnStart hook runs, but the engine constructor runs during fx resolution (before OnStart). Accessing .DB() lazily via the wrapper avoids the nil pointer panic.
9.6 KiB
9.6 KiB