Skip to content

ALTER COLUMN x SET NOT NULL no longer triggers adding-not-nullable-field as of v2.0.0 #519

@vicrep

Description

@vicrep

Version 1.5.4 introduced a regression where SET NO NULL was no longer triggering the adding-not-nullable-field warning. This was fixed in version 1.5.5 here: #412

Unfortunately, it seems that this fix did not survive the rewrite, as of version 2.0, the violation is no longer emitted.

Repro

Given the following migration, with pg_version set to ≥ 12

-- tmp-migration.sql

BEGIN;

-- Running upgrade a -> b

ALTER TABLE my_table ALTER COLUMN my_column SET NOT NULL;

UPDATE alembic_version SET version_num='b' WHERE alembic_version.version_num = 'a';

COMMIT;

Running on 1.6.1 (last version pre-rewrite):

npx -y squawk-cli@1.6.1 tmp-migration.sql
tmp-migration.sql:2:2: warning: adding-not-nullable-field

   2 | -- Running upgrade a -> b
   3 |
   4 | ALTER TABLE my_table ALTER COLUMN my_column SET NOT NULL;

  note: Setting a column NOT NULL blocks reads while the table is scanned.
  help: 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)

Running on v2.0.0 (note, the same applied on latest, i.e. 2.10.0)

npx -y squawk-cli@2.0.0 tmp-migration.sql

Found 0 issues in 1 file 🎉

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions