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"`
|
SlapID *uint32 `bun:"slap_id,unique" json:"slap_id"`
|
||||||
DiscordID string `bun:"discord_id,unique,notnull" json:"discord_id"`
|
DiscordID string `bun:"discord_id,unique,notnull" json:"discord_id"`
|
||||||
UserID *int `bun:"user_id,unique" json:"user_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:"-"`
|
User *User `bun:"rel:belongs-to,join:user_id=id" json:"-"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ type Config struct {
|
|||||||
OAuthScopes string // Authorisation scopes for OAuth
|
OAuthScopes string // Authorisation scopes for OAuth
|
||||||
RedirectPath string // ENV DISCORD_REDIRECT_PATH: Path for the OAuth redirect handler (required)
|
RedirectPath string // ENV DISCORD_REDIRECT_PATH: Path for the OAuth redirect handler (required)
|
||||||
BotToken string // ENV DISCORD_BOT_TOKEN: Token for the discord bot (required)
|
BotToken string // ENV DISCORD_BOT_TOKEN: Token for the discord bot (required)
|
||||||
|
GuildID string // ENV DISCORD_GUILD_ID: ID for the discord server the bot should connect to (required)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConfigFromEnv() (any, error) {
|
func ConfigFromEnv() (any, error) {
|
||||||
@@ -23,6 +24,7 @@ func ConfigFromEnv() (any, error) {
|
|||||||
OAuthScopes: getOAuthScopes(),
|
OAuthScopes: getOAuthScopes(),
|
||||||
RedirectPath: env.String("DISCORD_REDIRECT_PATH", ""),
|
RedirectPath: env.String("DISCORD_REDIRECT_PATH", ""),
|
||||||
BotToken: env.String("DISCORD_BOT_TOKEN", ""),
|
BotToken: env.String("DISCORD_BOT_TOKEN", ""),
|
||||||
|
GuildID: env.String("DISCORD_GUILD_ID", ""),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check required fields
|
// Check required fields
|
||||||
@@ -38,6 +40,9 @@ func ConfigFromEnv() (any, error) {
|
|||||||
if cfg.BotToken == "" {
|
if cfg.BotToken == "" {
|
||||||
return nil, errors.New("Envar not set: DISCORD_BOT_TOKEN")
|
return nil, errors.New("Envar not set: DISCORD_BOT_TOKEN")
|
||||||
}
|
}
|
||||||
|
if cfg.GuildID == "" {
|
||||||
|
return nil, errors.New("Envar not set: DISCORD_GUILD_ID")
|
||||||
|
}
|
||||||
|
|
||||||
return cfg, nil
|
return cfg, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,11 @@ const (
|
|||||||
LeaguesDelete Permission = "leagues.delete"
|
LeaguesDelete Permission = "leagues.delete"
|
||||||
|
|
||||||
// Teams permissions
|
// Teams permissions
|
||||||
TeamsCreate Permission = "teams.create"
|
TeamsCreate Permission = "teams.create"
|
||||||
TeamsUpdate Permission = "teams.update"
|
TeamsUpdate Permission = "teams.update"
|
||||||
TeamsDelete Permission = "teams.delete"
|
TeamsDelete Permission = "teams.delete"
|
||||||
TeamsAddToLeague Permission = "teams.add_to_league"
|
TeamsAddToLeague Permission = "teams.add_to_league"
|
||||||
|
TeamsManagePlayers Permission = "teams.manage_players"
|
||||||
|
|
||||||
// Users permissions
|
// Users permissions
|
||||||
UsersUpdate Permission = "users.update"
|
UsersUpdate Permission = "users.update"
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ templ SeasonLeagueTeams(season *db.Season, league *db.League, teams []*db.Team,
|
|||||||
} else {
|
} else {
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
for _, team := range teams {
|
for _, team := range teams {
|
||||||
<div class="bg-surface0 border border-surface1 rounded-lg p-6 hover:bg-surface1 transition-colors">
|
<div class="bg-surface0 border border-surface1 rounded-lg p-6 hover:bg-surface1 transition-colors hover:cursor-pointer">
|
||||||
<div class="flex justify-between items-start mb-3">
|
<div class="flex justify-between items-start mb-3">
|
||||||
<h3 class="text-xl font-bold text-text">{ team.Name }</h3>
|
<h3 class="text-xl font-bold text-text">{ team.Name }</h3>
|
||||||
if team.Color != "" {
|
if team.Color != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user