brackt/drizzle/0114_warm_swarm.sql
Claude 5cea6fd9b5
Convert season templates from season-based to sport-based for evergreen use
Templates previously referenced specific sports seasons (e.g. "NFL 2026"), requiring
admins to create a new template every year. Templates now reference sports directly
(e.g. "NFL") and resolve to the currently-draftable season at league-creation time.

- Remove `year` field from season_templates table
- Replace `sportsSeasonId` FK with `sportId` FK in season_template_sports
- applySportsFromTemplate now resolves each sport to its active draftable season
- Admin template UI updated to manage sports (not specific seasons)
- sports-data-sync export/import updated to the new sport-centric format

https://claude.ai/code/session_01CoRLHERakMncbPs877izvw
2026-06-04 17:54:16 +00:00

11 lines
No EOL
691 B
SQL

ALTER TABLE "season_template_sports" DROP CONSTRAINT "season_template_sports_sports_season_id_sports_seasons_id_fk";
--> statement-breakpoint
ALTER TABLE "season_template_sports" ADD COLUMN "sport_id" uuid NOT NULL;--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "season_template_sports" ADD CONSTRAINT "season_template_sports_sport_id_sports_id_fk" FOREIGN KEY ("sport_id") REFERENCES "public"."sports"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
ALTER TABLE "season_template_sports" DROP COLUMN IF EXISTS "sports_season_id";--> statement-breakpoint
ALTER TABLE "season_templates" DROP COLUMN IF EXISTS "year";