Add FK and CHECK constraints as NOT VALID, then VALIDATE CONSTRAINT separately to avoid a long blocking scan.
Why This Matters
Adding a constraint normally scans the whole table under a strong lock, blocking writes for the duration on large tables.
Related Rules
Catch this automatically on every PR
BeforeMerge scans your pull requests against this rule and dozens more. Get actionable feedback before code ships.