From d11ee978dc91403bea1d8b224d1526a9d391296a Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 26 Nov 2024 15:08:40 -0800 Subject: [PATCH] gorming --- internal/datastore/gormstore/db.go | 2 +- server.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/datastore/gormstore/db.go b/internal/datastore/gormstore/db.go index 6ff1321..c895e2e 100644 --- a/internal/datastore/gormstore/db.go +++ b/internal/datastore/gormstore/db.go @@ -38,7 +38,7 @@ func New(migrate bool) (datastore.Datastore, error) { sqlDB.SetMaxOpenConns(25) if migrate { - if err := db.AutoMigrate(&model.Time{}, &model.User{}, &model.Bot{}, &model.Submission{}, &model.Event{}, &model.Server{}, &model.Transaction{}, &model.Rank{}, &model.RankCalc{}); err != nil { + if err := db.AutoMigrate(&model.User{}, &model.Submission{}); err != nil { log.WithField("error", err).Errorln("database migration failed") return nil, err } diff --git a/server.go b/server.go index 5775e17..03eb057 100644 --- a/server.go +++ b/server.go @@ -8,6 +8,7 @@ import ( "git.itzana.me/strafesnet/maps-service/api" "git.itzana.me/strafesnet/maps-service/internal/controller/submissions" "git.itzana.me/strafesnet/maps-service/internal/controller/users" + "git.itzana.me/strafesnet/maps-service/internal/datastore/gormstore" ) type apiServer struct { @@ -29,10 +30,10 @@ func (m *apiServer) NewError(ctx context.Context, err error) *api.ErrorStatusCod } func main() { - // new grpc client - conn, err := grpc.Dial("localhost:9000", grpc.WithTransportCredentials(insecure.NewCredentials())) + db, err := gormstore.New(true) if err != nil { - log.Fatal(err) + log.WithField("error", err).Fatalln("database startup failed") + return } svc := &apiServer{