Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cmd/util/ignoreloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type TomlConfig struct {
Sequences SequenceIgnoreConfig `toml:"sequences,omitempty"`
Privileges PrivilegeIgnoreConfig `toml:"privileges,omitempty"`
DefaultPrivileges DefaultPrivilegeIgnoreConfig `toml:"default_privileges,omitempty"`
Constraints ConstraintsIgnoreConfig `toml:"constraints,omitempty"`
}
Comment on lines 36 to 41
Comment on lines 28 to 41
Comment on lines 28 to 41

// TableIgnoreConfig represents table-specific ignore configuration
Expand Down Expand Up @@ -80,6 +81,12 @@ type DefaultPrivilegeIgnoreConfig struct {
Patterns []string `toml:"patterns,omitempty"`
}

// ConstraintsIgnoreConfig represents default privilege-specific ignore configuration
// Patterns match on grantee role names
Comment thread
RicardoBorgesGO marked this conversation as resolved.
Outdated
type ConstraintsIgnoreConfig struct {
Patterns []string `toml:"patterns,omitempty"`
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Stale copy-pasted comment on ConstraintsIgnoreConfig

The doc comment for this type was copied verbatim from DefaultPrivilegeIgnoreConfig and still describes grantee role names, which is unrelated to constraints. Any reader trying to understand what patterns should look like will be misled into thinking they should supply role names instead of constraint names.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 No integration tests for the new constraints ignore section

Every other ignore category (tables, views, functions, sequences, privileges, default_privileges) has coverage in cmd/ignore_integration_test.go. A foreign-key scenario is the explicit motivation for this PR, yet there are no tests that verify a cross-schema FK is correctly filtered out of the dump/plan output. Without this, a regression (e.g., pattern not matching, scoping bug) would go undetected.


// LoadIgnoreFileWithStructure loads the .pgschemaignore file using the structured TOML format
// and converts it to the simple IgnoreConfig structure
func LoadIgnoreFileWithStructure() (*ir.IgnoreConfig, error) {
Expand Down Expand Up @@ -113,6 +120,7 @@ func LoadIgnoreFileWithStructureFromPath(filePath string) (*ir.IgnoreConfig, err
Sequences: tomlConfig.Sequences.Patterns,
Privileges: tomlConfig.Privileges.Patterns,
DefaultPrivileges: tomlConfig.DefaultPrivileges.Patterns,
Constraints: tomlConfig.Constraints.Patterns,
}

return config, nil
Expand Down
9 changes: 9 additions & 0 deletions ir/ignore.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type IgnoreConfig struct {
Sequences []string `toml:"sequences,omitempty"`
Privileges []string `toml:"privileges,omitempty"`
DefaultPrivileges []string `toml:"default_privileges,omitempty"`
Constraints []string `toml:"constraints,omitempty"`
Comment on lines 23 to +27
}

// ShouldIgnoreTable checks if a table should be ignored based on the patterns
Expand Down Expand Up @@ -114,6 +115,14 @@ func (c *IgnoreConfig) ShouldIgnoreDefaultPrivilege(grantee string) bool {
return c.shouldIgnore(grantee, c.DefaultPrivileges)
}

// ShouldIgnoreConstraints checks if constraints should be ignored based on the patterns
func (c *IgnoreConfig) ShouldIgnoreConstraints(constraintName string) bool {
Comment thread
RicardoBorgesGO marked this conversation as resolved.
Outdated
if c == nil {
return false
}
return c.shouldIgnore(constraintName, c.Constraints)
Comment on lines +120 to +124
}
Comment on lines +119 to +125
Comment on lines +119 to +125

// shouldIgnore checks if a name should be ignored based on the patterns
// Patterns support wildcards (*) and negation (!)
// Negation patterns (starting with !) take precedence over inclusion patterns
Expand Down
5 changes: 5 additions & 0 deletions ir/inspector.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,11 @@ func (i *Inspector) buildConstraints(ctx context.Context, schema *IR, targetSche
constraintType = constraint.ConstraintType.String
}

// Check if constraint should be ignored
if i.ignoreConfig != nil && i.ignoreConfig.ShouldIgnoreConstraints(constraintName) {
Comment thread
RicardoBorgesGO marked this conversation as resolved.
Outdated
continue
}

// Extract column name from sql.NullString
columnName := ""
if constraint.ColumnName.Valid {
Expand Down