Skip to content

Commit

Permalink
feat: add model auto migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
peterxcli committed Jan 13, 2024
1 parent 98a32d4 commit b0ee30d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bikefest/docs"
"bikefest/pkg/bootstrap"
"bikefest/pkg/model"
"bikefest/pkg/router"
"bikefest/pkg/service"
"fmt"
Expand Down Expand Up @@ -50,6 +51,16 @@ func main() {
// init config
app := bootstrap.App()

// TODO: needs to consider whether migrate the db schema everytime the service boot
err := app.Conn.AutoMigrate(
&model.User{},
&model.Event{},
&model.PsychoTest{},
)
if err != nil {
panic(err)
}

// init services
userService := service.NewUserService(app.Conn, app.Cache)
eventService := service.NewEventService(app.Conn, app.Cache)
Expand Down

0 comments on commit b0ee30d

Please sign in to comment.