← all rules

drop-not-null

warning

ALTER COLUMN DROP NOT NULL

Why it's unsafe

ALTER COLUMN … DROP NOT NULL removes a not-null invariant that application code, ORMs, and the query planner may rely on — nulls can now appear where callers assume they cannot.

Safe rewrite

Confirm nothing depends on the column being non-null (planner assumptions, ORM models, application code) before dropping the constraint.

Example

Try it in the playground →

Unsafe

ALTER TABLE users ALTER COLUMN email DROP NOT NULL;

Related