This commit is contained in:
Quaternions 2024-11-26 15:08:40 -08:00
parent ee7790dd39
commit d11ee978dc
2 changed files with 5 additions and 4 deletions

View File

@ -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
}

View File

@ -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{