deadhead-space-freight-tycoon/apps/server/drizzle/0009_cr013_ship_from_deal.sql

6 lines
338 B
SQL

ALTER TABLE "ships" ADD COLUMN "from_deal" boolean DEFAULT false NOT NULL;--> statement-breakpoint
-- Backfill: each player's first ship came with the deal (CR-001), not from the Market.
UPDATE "ships" SET "from_deal" = true WHERE "id" IN (
SELECT DISTINCT ON ("player_id") "id" FROM "ships" ORDER BY "player_id", "created_at", "id"
);