Skip to content

linter: add cross-file validation for NOT NULL constraint pattern#957

Open
reteps wants to merge 2 commits intosbdchd:masterfrom
reteps:cross-file-validation
Open

linter: add cross-file validation for NOT NULL constraint pattern#957
reteps wants to merge 2 commits intosbdchd:masterfrom
reteps:cross-file-validation

Conversation

@reteps
Copy link
Contributor

@reteps reteps commented Feb 24, 2026

This PR was generated with Claude, feel free to use this as a starting point, or I can split this out into an issue.


Generally, I want to be able to track the NOT NULL constraints across migration files as our postgres deployments have a transaction-per-file, and so I do the constraint in a different, earlier migration than the SET NOT NULL change.

Summary

  • Support the cross-migration pattern where ADD CONSTRAINT ... NOT VALID is in a previous migration file and only VALIDATE CONSTRAINT + SET NOT NULL appear in the current file
  • Track tables with externally validated constraints so that SET NOT NULL after VALIDATE CONSTRAINT is not flagged as an error (this was causing me issues in linter: fix adding-not-nullable-field for pg >= 12 with validated CHECK #910 )
  • Add tests for PG 12+, 16+, and PG 11 (which correctly still errors)

Follow up to #910

Test plan

  • Added pg16_cross_migration_validate_then_set_not_null_ok test
  • Added pg12_cross_migration_validate_then_set_not_null_ok test
  • Added pg11_cross_migration_validate_then_set_not_null_err test (PG 11 correctly rejects)

🤖 Generated with Claude Code

@netlify
Copy link

netlify bot commented Feb 24, 2026

👷 Deploy request for squawkhq pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit edea462

@reteps reteps changed the title Add cross-file validation for NOT NULL constraint pattern linter: add cross-file validation for NOT NULL constraint pattern Feb 24, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant