brackt/drizzle/0069_draft_window.sql
Claude d7e1c380a6
Preserve original migration tags and SQL to match production hashes
Restores the original tag name (0068_cs2_major_simulator) and exact SQL
content for migrations 0068 and 0069 so their hashes match what's already
recorded in the production __drizzle_migrations table. Also fixes the
snapshot id/prevId chain to use consistent tag-based identifiers.

https://claude.ai/code/session_01JuVHpRPa974MKSHoXNGkgU
2026-04-06 14:44:29 +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";