Adding NOT NULL to an existing column requires a full table scan and exclusive lock.
Why This Matters
ALTER TABLE ... SET NOT NULL acquires an ACCESS EXCLUSIVE lock and scans every row to verify the constraint, causing downtime on large tables.
Tags
SquawkpostgresqlMigration Safety
Related Rules
Catch this automatically on every PR
BeforeMerge scans your pull requests against this rule and 3+ others. Get actionable feedback before code ships.