-
Notifications
You must be signed in to change notification settings - Fork 55
Open
Labels
Description
Likely related to #300 and #519, but following the rules solution for adding-not-nullable-field on pg-version 16 and using the additional ALTER COLUMN bar SET NOT NULL as suggested here (https://squawkhq.com/docs/adding-not-nullable-field) raises an error.
Attached a minimal reproduction case:
-- test.sql
BEGIN;
ALTER TABLE foo ADD COLUMN bar BIGINT;
ALTER TABLE foo ADD CONSTRAINT bar_not_null CHECK (bar IS NOT NULL) NOT VALID;
COMMIT;
BEGIN;
ALTER TABLE foo VALIDATE CONSTRAINT bar_not_null;
ALTER TABLE foo ALTER COLUMN bar SET NOT NULL;
ALTER TABLE foo DROP CONSTRAINT bar_not_null;
COMMIT;squawk test.sql --pg-version 16
warning[adding-not-nullable-field]: Setting a column `NOT NULL` blocks reads while the table is scanned.
--> test.sql:15:34
|
15 | ALTER TABLE foo ALTER COLUMN bar SET NOT NULL;
| ------------
|
= help: Make the field nullable and use a `CHECK` constraint instead.
Find detailed examples and solutions for each rule at https://squawkhq.com/docs/rules
Found 1 issue in 1 file (checked 1 source file)