big ole refactor

This commit is contained in:
2026-02-14 19:48:59 +11:00
parent f0e7962af5
commit 8a79533de3
66 changed files with 989 additions and 1114 deletions

View File

@@ -0,0 +1,49 @@
package migrations
import (
"context"
"git.haelnorr.com/h/oslstats/internal/db"
"github.com/uptrace/bun"
)
func init() {
Migrations.MustRegister(
// UP migration
func(ctx context.Context, conn *bun.DB) error {
// Add your migration code here
_, err := conn.NewCreateTable().
Model((*db.Team)(nil)).
Exec(ctx)
if err != nil {
return err
}
_, err = conn.NewCreateTable().
Model((*db.TeamParticipation)(nil)).
Exec(ctx)
if err != nil {
return err
}
return nil
},
// DOWN migration
func(ctx context.Context, conn *bun.DB) error {
// Add your rollback code here
_, err := conn.NewDropTable().
Model((*db.TeamParticipation)(nil)).
IfExists().
Exec(ctx)
if err != nil {
return err
}
_, err = conn.NewDropTable().
Model((*db.Team)(nil)).
IfExists().
Exec(ctx)
if err != nil {
return err
}
return nil
},
)
}