Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #167 where foreign key constraints referencing ignored tables were being lost in multi-file dumps. The fix addresses the root cause in the dump formatter by ensuring constraints are properly grouped with their parent tables.
Key Changes:
- Added
DiffTypeTableConstrainthandling to formatter grouping logic to group constraints with tables - Added "table.constraint" case to route constraints to the tables directory instead of misc
- Enhanced integration tests to verify FK constraints, triggers, and views on ignored tables work in both single-file and multi-file dumps
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/dump/formatter.go | Added constraint handling to getObjectDirectory(), getGroupingName(), and extractTableNameFromContext() to ensure constraints are grouped with their parent tables in multi-file dumps |
| cmd/ignore_integration_test.go | Renamed and expanded test to comprehensively verify dependencies (FK constraints, triggers, views) on ignored tables work correctly in both single-file and multi-file dump modes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
**Problem:** Foreign key constraints referencing ignored tables were being lost in multi-file dumps (--multi-file flag). Single-file dumps worked correctly. **Root Cause:** In internal/dump/formatter.go, two issues prevented constraints from being properly grouped with their tables in multi-file output: 1. DiffTypeTableConstraint was missing from getGroupingName() switch statement, so constraints weren't grouped with their parent tables 2. "table.constraint" was missing from getObjectDirectory() case statement, so constraints went to "misc" directory instead of "tables" **Solution:** - Added DiffTypeTableConstraint to getGroupingName() to group constraints with their tables (line 252) - Added "table.constraint" to getObjectDirectory() case statement to route constraints to tables directory (line 246) - Added *ir.Constraint case to extractTableNameFromContext() to extract table name from constraint objects (line 335) **Testing:** - Added comprehensive test testDependenciesOnIgnoredTables() that verifies FK constraints, triggers, and views referencing ignored tables are preserved in both single-file and multi-file dumps - Consolidated 5 redundant test functions into 1 comprehensive test - Reduced test file from 1450 to 980 lines (32% reduction) - All existing tests pass **Documentation:** - Updated docs/cli/ignore.mdx to document allowlist patterns and dependencies on ignored tables Fixes #167 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #167
Problem:
Foreign key constraints referencing ignored tables were being lost in multi-file dumps (--multi-file flag). Single-file dumps worked correctly.
Root Cause:
In internal/dump/formatter.go, two issues prevented constraints from being properly grouped with their tables in multi-file output:
Solution: