added player names

This commit is contained in:
2026-02-19 20:48:31 +11:00
parent 970346f15d
commit 98b110ee44
5 changed files with 43 additions and 5 deletions

View File

@@ -0,0 +1,31 @@
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.NewAddColumn().
Model((*db.Player)(nil)).
IfNotExists().
ColumnExpr("name VARCHAR NOT NULL").
Exec(ctx)
if err != nil {
return err
}
return nil
},
// DOWN migration
func(ctx context.Context, conn *bun.DB) error {
// Add your rollback code here
return nil
},
)
}

View File

@@ -14,6 +14,7 @@ type Player struct {
SlapID *uint32 `bun:"slap_id,unique" json:"slap_id"`
DiscordID string `bun:"discord_id,unique,notnull" json:"discord_id"`
UserID *int `bun:"user_id,unique" json:"user_id"`
Name string `bun:"name,notnull" json:"name"`
User *User `bun:"rel:belongs-to,join:user_id=id" json:"-"`
}