only postgres14 atlas migrate lint --dir file://migrations1 --dev-url URL --latest=1 > got.txt cmp got.txt expected1.txt atlas migrate lint --dir file://migrations2 --dev-url URL --latest=1 > got.txt cmp got.txt expected2.txt atlas migrate lint --dir file://migrations3 --dev-url URL --latest=1 > got.txt cmp got.txt empty.txt atlas migrate lint --dir file://migrations4 --dev-url URL --latest=1 > got.txt cmp got.txt expected4.txt -- empty.txt -- -- migrations1/1.sql -- CREATE TABLE users (id int); -- migrations1/2.sql -- ALTER TABLE users ADD COLUMN "rank" int NULL DEFAULT 1; ALTER TABLE users ALTER COLUMN "id" SET NOT NULL; -- expected1.txt -- 2.sql: data dependent changes detected: L2: Modifying nullable column "id" to non-nullable might fail in case it contains NULL values -- migrations2/1.sql -- CREATE TABLE users (id int); -- migrations2/2.sql -- -- Add (a, b, c), backfill (a, b) and then modify all to not-null. ALTER TABLE users ADD COLUMN "a" int, ADD COLUMN "b" int, ADD COLUMN "c" int; UPDATE users SET "a" = 1; UPDATE users SET "b" = 1 WHERE "b" IS NULL; ALTER TABLE users ALTER COLUMN "a" SET NOT NULL, ALTER COLUMN "b" SET NOT NULL, ALTER COLUMN "c" SET NOT NULL; -- expected2.txt -- 2.sql: data dependent changes detected: L5: Modifying nullable column "c" to non-nullable might fail in case it contains NULL values -- migrations3/1.sql -- CREATE TABLE users (id int); ALTER TABLE users ALTER COLUMN "id" SET NOT NULL; -- migrations4/1.sql -- CREATE TABLE users (id int); CREATE TABLE pets (id int); -- migrations4/2.sql -- ALTER TABLE users ADD COLUMN name varchar(255), ADD COLUMN age float; UPDATE users SET name = 'Unknown', age = 0; -- No diagnostics. ALTER TABLE users ALTER COLUMN name SET NOT NULL, ALTER COLUMN age SET NOT NULL; ALTER TABLE pets ADD COLUMN name varchar(255), ADD COLUMN age float; UPDATE pets SET name = 'Unknown', age = 0 WHERE random() > 0.5; -- With diagnostics as statement above cannot be sure NULL values are back-filled. ALTER TABLE pets ALTER COLUMN name SET NOT NULL, ALTER COLUMN age SET NOT NULL; -- expected4.txt -- 2.sql: data dependent changes detected: L9: Modifying nullable column "name" to non-nullable might fail in case it contains NULL values L9: Modifying nullable column "age" to non-nullable might fail in case it contains NULL values