Cleaned up table creations

This commit is contained in:
cdricms
2025-01-29 18:42:06 +01:00
parent 2d5747ec08
commit 0ee1c1e4a7

View File

@@ -39,17 +39,39 @@ func InitDatabase(dsn DSN) (*bun.DB, error) {
db.RegisterModel((*m.EventToUser)(nil))
db.RegisterModel((*m.PermissionToRole)(nil))
db.RegisterModel((*m.UserToRole)(nil))
_, err = db.NewCreateTable().Model((*m.User)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().Model((*m.Event)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().Model((*m.EventToUser)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().Model((*m.Blog)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().Model((*m.WebsiteSettings)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().Model((*m.Media)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().Model((*m.Shortcode)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().Model((*m.Role)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().Model((*m.Permission)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().Model((*m.PermissionToRole)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().Model((*m.UserToRole)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().
Model((*m.User)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().
Model((*m.Event)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().
Model((*m.EventToUser)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().
Model((*m.Blog)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().
Model((*m.WebsiteSettings)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().
Model((*m.Media)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().
Model((*m.Shortcode)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().
Model((*m.Role)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().
Model((*m.Permission)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().
Model((*m.PermissionToRole)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().
Model((*m.UserToRole)(nil)).IfNotExists().Exec(ctx)
if err != nil {
return nil, err
}