brackt/drizzle/0069_draft_window.sql
Claude 6dbda8465f
Replace isDraftable boolean with draftOn/draftOff date fields on sport seasons
Admins can now schedule when a sport season becomes available for drafting
by setting explicit open and close dates instead of a manual toggle.

https://claude.ai/code/session_01LHYgpyimF8v8odUB6kj8Qc
2026-04-06 01:51:19 +00:00

19 lines
843 B
SQL

-- Step 1: Add new columns as nullable
ALTER TABLE "sports_seasons" ADD COLUMN "draft_on" date;--> statement-breakpoint
ALTER TABLE "sports_seasons" ADD COLUMN "draft_off" date;--> statement-breakpoint
-- Step 2: Backfill data based on existing is_draftable flag
UPDATE "sports_seasons"
SET "draft_on" = '2026-04-06', "draft_off" = '2099-12-31'
WHERE "is_draftable" = true;--> statement-breakpoint
UPDATE "sports_seasons"
SET "draft_on" = '2020-01-01', "draft_off" = '2020-12-31'
WHERE "is_draftable" = false;--> statement-breakpoint
-- Step 3: Apply NOT NULL constraints
ALTER TABLE "sports_seasons" ALTER COLUMN "draft_on" SET NOT NULL;--> statement-breakpoint
ALTER TABLE "sports_seasons" ALTER COLUMN "draft_off" SET NOT NULL;--> statement-breakpoint
-- Step 4: Drop old column
ALTER TABLE "sports_seasons" DROP COLUMN "is_draftable";