CardDealer.AI← Home
All known issues
KI-002 · Orders & Shipping

Returns table foreign key blocked container boot

MediumFixed
Filed
May 22, 2026, 11:30 PM
Last update
May 23, 2026, 12:30 AM
Resolved
May 23, 2026, 12:30 AM

What we know

What happened

The deploy that introduced the eBay returns surface (/orders/returns) put the new container into a crash loop. Every boot, the migrate-on-boot script tried to apply 0096_ebay_returns.sql and Postgres rejected the foreign key — the new table's user_id column was declared uuid, but the actual user table's id column is text.

Root cause

The Drizzle schema export for the user table is named users (plural), but the underlying Postgres table is "user" (singular, and a SQL reserved word). When I hand-wrote the migration SQL, I matched the export name and assumed uuid for the FK column type. Both were wrong: the table name needed quoting and the column type needed to be text.

Fix

Changed both columns from uuid to text and pushed the corrected migration. The migrate-on-boot transaction-per-migration pattern meant the failed attempt left zero state behind — the next deploy retried 0096 cleanly and the site came back.

What we learned

Before writing new schema, copy the closest existing migration file (e.g. lib/db/schema/easypost-shipments.ts) rather than typing column types from memory. The same FK pattern is repeated everywhere; the right shape was visible all along.

Get notified when this changes

We'll email you when the status flips — typically when a workaround lands or the fix ships.

Sign in to subscribe

See something we missed? Email us with the KI-002 reference and we'll fold any new info in.