Skip to content

Commit

Permalink
fix: dereference pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
pcfreak30 committed Oct 31, 2024
1 parent 4d581da commit 1bef772
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ func (p *PortalImpl) initModels(ctx core.Context, dbInst *gorm.DB) (ctxOpts []co
ctxOpts = append(ctxOpts, core.ContextWithStartupFunc(func(ctx core.Context) error {
for _, model := range models {
typ := reflect.TypeOf(model)
// Get the underlying type if it's a pointer
if typ.Kind() == reflect.Ptr {
typ = typ.Elem()
}
if err = dbInst.AutoMigrate(model); err != nil {
ctx.Logger().Error("Error migrating model", zap.String("model", typ.Name()), zap.Error(err))
return err
Expand Down

0 comments on commit 1bef772

Please sign in to comment.