Skip to content

MG29 — ALTER DOMAIN ADD CONSTRAINT validates under a lock

Group: Migration safety · Auto-fixable: no

ALTER DOMAIN ADD CONSTRAINT revalidates every column of the domain across every table under a lock. Add it NOT VALID and VALIDATE separately, or use table constraints instead.

bad: ALTER DOMAIN d ADD CONSTRAINT c CHECK (VALUE > 0);
good: ALTER DOMAIN d ADD CONSTRAINT c CHECK (VALUE > 0) NOT VALID;

Disable this rule in banshee.toml:

[lint]
exclude = ["MG29"]

Or silence one line with -- noqa: MG29. See Linting.