added player names
This commit is contained in:
31
internal/db/migrations/20260219203524_player_names.go
Normal file
31
internal/db/migrations/20260219203524_player_names.go
Normal 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
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -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:"-"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user