From 56b79e142e627589f20cc5fcd527f4e33271b867 Mon Sep 17 00:00:00 2001 From: Z8MB1E Date: Sun, 16 Aug 2026 18:23:33 -0400 Subject: [PATCH] fix(migrations): backfill grid columns before NOT NULL on data-bearing table The generated migration added grid_x/grid_y as numeric NOT NULL without a default, which fails on prod where game_structures_stored_resources already has rows ('column contains null values'). Add the columns with DEFAULT 0 to backfill existing rows, then drop the default to match the target schema. --- src/migrations/20260816_213455.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/migrations/20260816_213455.ts b/src/migrations/20260816_213455.ts index 9681e92..b85245c 100644 --- a/src/migrations/20260816_213455.ts +++ b/src/migrations/20260816_213455.ts @@ -376,8 +376,10 @@ export async function up({ db, payload, req }: MigrateUpArgs): Promise { ALTER TABLE "missions" ALTER COLUMN "game_details_game_setup_mission_file_id" DROP NOT NULL; ALTER TABLE "structures_auto_generated_resources" ALTER COLUMN "min_frequency" SET DEFAULT '1'; - ALTER TABLE "game_structures_stored_resources" ADD COLUMN "grid_x" numeric NOT NULL; - ALTER TABLE "game_structures_stored_resources" ADD COLUMN "grid_y" numeric NOT NULL; + ALTER TABLE "game_structures_stored_resources" ADD COLUMN "grid_x" numeric DEFAULT 0 NOT NULL; + ALTER TABLE "game_structures_stored_resources" ADD COLUMN "grid_y" numeric DEFAULT 0 NOT NULL; + ALTER TABLE "game_structures_stored_resources" ALTER COLUMN "grid_x" DROP DEFAULT; + ALTER TABLE "game_structures_stored_resources" ALTER COLUMN "grid_y" DROP DEFAULT; ALTER TABLE "game_structures_stored_resources" ADD COLUMN "rotated" boolean DEFAULT false; ALTER TABLE "game_structures" ADD COLUMN "faction_id" integer; ALTER TABLE "users" ADD COLUMN "discord_id" varchar;