diff --git a/drizzle/0068_soft_silk_fever.sql b/drizzle/0068_cs2_major_simulator.sql similarity index 98% rename from drizzle/0068_soft_silk_fever.sql rename to drizzle/0068_cs2_major_simulator.sql index aeaa985..3d1e8b9 100644 --- a/drizzle/0068_soft_silk_fever.sql +++ b/drizzle/0068_cs2_major_simulator.sql @@ -23,4 +23,4 @@ EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint -CREATE UNIQUE INDEX IF NOT EXISTS "cs2_major_stage_results_unique" ON "cs2_major_stage_results" USING btree ("scoring_event_id","participant_id"); \ No newline at end of file +CREATE UNIQUE INDEX IF NOT EXISTS "cs2_major_stage_results_unique" ON "cs2_major_stage_results" USING btree ("scoring_event_id","participant_id"); diff --git a/drizzle/0069_draft_window.sql b/drizzle/0069_draft_window.sql index 9f4a686..fe4bf4c 100644 --- a/drizzle/0069_draft_window.sql +++ b/drizzle/0069_draft_window.sql @@ -1,18 +1,19 @@ --- Step 1: Add new columns as nullable (IF NOT EXISTS for idempotency) -ALTER TABLE "sports_seasons" ADD COLUMN IF NOT EXISTS "draft_on" date;--> statement-breakpoint -ALTER TABLE "sports_seasons" ADD COLUMN IF NOT EXISTS "draft_off" date;--> statement-breakpoint +-- 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 (only if column still exists) -DO $$ BEGIN - IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'sports_seasons' AND column_name = 'is_draftable') THEN - UPDATE "sports_seasons" SET "draft_on" = '2026-04-06', "draft_off" = '2099-12-31' WHERE "is_draftable" = true; - UPDATE "sports_seasons" SET "draft_on" = '2020-01-01', "draft_off" = '2020-12-31' WHERE "is_draftable" = false; - END IF; -END $$;--> 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 (IF EXISTS for idempotency) -ALTER TABLE "sports_seasons" DROP COLUMN IF EXISTS "is_draftable"; +-- Step 4: Drop old column +ALTER TABLE "sports_seasons" DROP COLUMN "is_draftable"; diff --git a/drizzle/meta/0068_snapshot.json b/drizzle/meta/0068_snapshot.json index bfbf43f..38996cc 100644 --- a/drizzle/meta/0068_snapshot.json +++ b/drizzle/meta/0068_snapshot.json @@ -1,5 +1,5 @@ { - "id": "36896379-5f24-4c5a-9920-b5bb96f34b8e", + "id": "0068_cs2_major_simulator", "prevId": "0067_darts_bracket", "version": "7", "dialect": "postgresql", @@ -4462,4 +4462,4 @@ "schemas": {}, "tables": {} } -} \ No newline at end of file +} diff --git a/drizzle/meta/0069_snapshot.json b/drizzle/meta/0069_snapshot.json index 300aa9a..b21fe07 100644 --- a/drizzle/meta/0069_snapshot.json +++ b/drizzle/meta/0069_snapshot.json @@ -1,6 +1,6 @@ { - "id": "05dcbcde-8087-46f0-81da-99299a36e2e9", - "prevId": "36896379-5f24-4c5a-9920-b5bb96f34b8e", + "id": "0069_draft_window", + "prevId": "0068_cs2_major_simulator", "version": "7", "dialect": "postgresql", "tables": { diff --git a/drizzle/meta/0070_snapshot.json b/drizzle/meta/0070_snapshot.json index 7b263b7..0108be3 100644 --- a/drizzle/meta/0070_snapshot.json +++ b/drizzle/meta/0070_snapshot.json @@ -1,6 +1,6 @@ { - "id": "6949c47a-4107-4053-b87a-f7fbc6560dd5", - "prevId": "05dcbcde-8087-46f0-81da-99299a36e2e9", + "id": "0070_verify_migrations", + "prevId": "0069_draft_window", "version": "7", "dialect": "postgresql", "tables": { @@ -4467,4 +4467,4 @@ "schemas": {}, "tables": {} } -} \ No newline at end of file +} diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index c239d17..1f55e9c 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -482,7 +482,7 @@ "idx": 68, "version": "7", "when": 1775485575205, - "tag": "0068_soft_silk_fever", + "tag": "0068_cs2_major_simulator", "breakpoints": true }, {