Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
avoronov-box opened this issue Aug 4, 2023 · 1 comment

Comments

@avoronov-box
Copy link

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
Copy link
Collaborator

chdsbd commented Aug 5, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants