sbdchd/squawk

`constraint-missing-not-valid` should also forbid constraints when adding a column

Opened this issue · 1 comments

Adding a column with a constraint directly causes the same locking issue as adding a constraint:

ALTER TABLE "some_table" ADD COLUMN "some_field" integer NULL CHECK ("some_field" >= 0);

Currently squawk does not report this as a violation. Would be great to catch this.

chdsbd commented

I believe this is okay, there will be some locking when modify a table schema in Postgres. I think as long as the locking is short, it will be okay for a production system.

When adding a null field, Postgres will take almost no time to verify the check constraint, because there aren't any rows with the new column

There's some docs on safely applying migrations to prevent locks from breaking a running application: https://squawkhq.com/docs/safe_migrations