Migration Guard › sample report 3
ALTER COLUMN TYPE
Illustrative: written by hand to show the report format. The Action is not built yet, and this statement is a minimal synthetic example, not taken from a real repository.
| Statement | ALTER TABLE orders ALTER COLUMN total TYPE bigint; |
|---|---|
| Lock taken | ACCESS EXCLUSIVE on orders. It blocks all reads and writes while held. |
| Rewrites the table | Yes for int to bigint: the types are not binary-coercible, so the table and its indexes on that column are rewritten under the lock. Some other type changes avoid a rewrite; see the ALTER TABLE docs. |
| Verdict | BLOCK-RISK |
Why
The rewrite runs while all reads and writes on the table are blocked, so the outage lasts at least as long as the rewrite.
Lower-risk rewrite
A common lower-risk pattern is to add a new column, backfill in batches, then swap over in a later release. Review each step for its own lock:
ALTER TABLE orders ADD COLUMN total_new bigint; -- backfill in batches outside this migration -- deploy application code that writes both columns, then reads the new one -- later: drop the old column and rename the new one (each takes ACCESS EXCLUSIVE briefly)
Sources: PostgreSQL docs: explicit locking; PostgreSQL docs: ALTER TABLE (notes on ALTER COLUMN TYPE).
Table size is unknown to this report. Statements outside the fixed rule list would be marked REVIEW.