Safety Rules
Destructive operation blocking
Section titled “Destructive operation blocking”By default, pgmold blocks destructive operations:
DROP TABLE,DROP COLUMN,DROP ENUMrequire--allow-destructive- Type narrowing and
SET NOT NULLproduce warnings
# This will fail if the plan includes any dropspgmold apply -s sql:schema.sql -d postgres://localhost/mydb
# Explicitly opt in to destructive operationspgmold apply -s sql:schema.sql -d postgres://localhost/mydb --allow-destructiveProduction mode
Section titled “Production mode”Set PGMOLD_PROD=1 for production mode, which blocks table drops entirely — even with --allow-destructive.
PGMOLD_PROD=1 pgmold apply -s sql:schema.sql -d postgres://localhost/prodLock hazard warnings
Section titled “Lock hazard warnings”pgmold warns about operations that acquire heavy locks, such as:
- Adding a column with a default value (rewrites the table in older PostgreSQL versions)
- Adding a
NOT NULLconstraint without a default - Creating an index without
CONCURRENTLY
These warnings help prevent downtime during migrations on large tables.