Skip to content

.tip

· one of the small things

Rename a column by expanding, then contracting

ALTER TABLE ... RENAME COLUMN only touches the catalog and commits in milliseconds, which is what makes it dangerous: the processes already running still select the old name and fail the instant it lands. Expand first instead.

ALTER TABLE users ADD COLUMN full_name text;
-- then write both columns from the app and backfill in batches

Ship the dual write, backfill until it reports zero rows, move reads to full_name, and drop name a deploy later. Each step works with the old code and the new one, so no deploy needs every process restarted at the same instant.

migrationsschema-design