coding · Gemini · free
Write a Postgres migration for this change. Change wanted: [DESCRIBE — new column / new table / rename / backfill] Current schema of affected tables: [PASTE OR DESCRIBE] Table size: [ROW COUNT] Downtime tolerance: [ZERO / SECONDS / MINUTES] Deliver up and down SQL that is: Online safe for a table this size — no ALTER TABLE ... ADD COLUMN NOT NULL without default, no ALTER TABLE ... ALTER TYPE on hot columns Split into phases if needed: add nullable → backfill in batches → set NOT NULL → drop old Wrapped in a transaction only where safe (index builds and enum adds are not) CREATE INDEX CONCURRENTLY for anything on a large table Includes a SELECT sanity check that would fail loudly if the migration half ran Idempotent where reasonable (IF NOT EXISTS) A down that actually works — not a comment saying "irreversible" At the top: a comment block listing the phases and the deploy order relative to app code.
#postgres #migrations #database