added season types and changed new season to be a modal
This commit is contained in:
@@ -55,13 +55,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Remove slap_version column from seasons table
|
||||
_, err = conn.NewDropColumn().
|
||||
Model((*db.Season)(nil)).
|
||||
ColumnExpr("slap_version").
|
||||
Exec(ctx)
|
||||
return err
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
63
internal/db/migrations/20260218185128_add_type_to_seasons.go
Normal file
63
internal/db/migrations/20260218185128_add_type_to_seasons.go
Normal file
@@ -0,0 +1,63 @@
|
||||
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.Season)(nil)).
|
||||
IfNotExists().
|
||||
ColumnExpr("type VARCHAR NOT NULL").
|
||||
Exec(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
leagues := []db.League{
|
||||
{
|
||||
Name: "Pro League",
|
||||
ShortName: "Pro",
|
||||
Description: "For the most experienced Slapshotters in OSL",
|
||||
},
|
||||
{
|
||||
Name: "Intermediate League",
|
||||
ShortName: "IM",
|
||||
Description: "For returning players who've been practicing in RPUGs and PUBs",
|
||||
},
|
||||
{
|
||||
Name: "Open League",
|
||||
ShortName: "Open",
|
||||
Description: "For new players just getting started with Slapshot",
|
||||
},
|
||||
{
|
||||
Name: "Draft League",
|
||||
ShortName: "Draft",
|
||||
Description: "A league where teams are selected by a draft system",
|
||||
},
|
||||
}
|
||||
for _, league := range leagues {
|
||||
_, err = conn.NewInsert().
|
||||
Model(&league).
|
||||
On("CONFLICT DO NOTHING").
|
||||
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
|
||||
},
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user