From b0ee30d1f51aca39a172ef8e0a53bf520ea61e12 Mon Sep 17 00:00:00 2001 From: peterxcli Date: Sun, 14 Jan 2024 02:51:31 +0800 Subject: [PATCH] feat: add model auto migrate --- cmd/main.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/main.go b/cmd/main.go index 6abb231..1d2553b 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -3,6 +3,7 @@ package main import ( "bikefest/docs" "bikefest/pkg/bootstrap" + "bikefest/pkg/model" "bikefest/pkg/router" "bikefest/pkg/service" "fmt" @@ -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)