feat: add triggers section to .pgschemaignore (#407)#453
Merged
Conversation
Adds a new [triggers] section to .pgschemaignore that matches triggers by name (glob). Ignored triggers are filtered at the inspector, so they are excluded from dump, plan generation, and drift detection alike — pgschema neither creates, drops, nor reports them. Use case: extensions that automatically create triggers on tracked tables (e.g. the pgai vectorizer's _vectorizer_src_trg_* triggers) would otherwise be flagged for drop by `pgschema plan`. Ignoring them by name keeps the rest of the table managed while leaving those triggers out-of-band. Mirrors the existing per-object pattern (Constraints, #447): Triggers []string on IgnoreConfig with ShouldIgnoreTrigger(name), a TriggerIgnoreConfig struct on TomlConfig, and a filter in the inspector's buildTriggers loop. Fixes #407 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR adds trigger-level ignore support to
Confidence Score: 5/5This looks safe to merge.
Reviews (1): Last reviewed commit: "feat: add triggers section to .pgschemai..." | Re-trigger Greptile |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for ignoring PostgreSQL triggers by name via a new [triggers] section in .pgschemaignore, so extension-managed triggers can be excluded from dump, plan generation, and drift detection.
Changes:
- Extend ignore configuration (
ir.IgnoreConfig) with trigger patterns and matching (ShouldIgnoreTrigger). - Filter ignored triggers during IR inspection (
Inspector.buildTriggers), excluding them from the inspected state. - Wire TOML loading + docs + unit/integration tests for the new
[triggers]section.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
ir/inspector.go |
Skips triggers whose names match ignore patterns during trigger inspection. |
ir/ignore.go |
Adds Triggers []string and ShouldIgnoreTrigger(name) to ignore config. |
ir/ignore_test.go |
Adds unit coverage for trigger ignore matching and nil-config behavior. |
cmd/util/ignoreloader.go |
Adds TOML [triggers] parsing and maps it into ir.IgnoreConfig. |
cmd/util/ignoreloader_test.go |
Verifies [triggers] patterns are loaded from TOML. |
cmd/ignore_integration_test.go |
Adds integration test ensuring ignored triggers are excluded from dump/plan outputs. |
docs/cli/ignore.mdx |
Documents the new [triggers] section with example and warning. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address Copilot review on #453: - Reuse set_updated_at() for the ignored trigger instead of a separate vectorizer_noop() function, so the only unmanaged object in the plan subtest is the ignored trigger itself (no stray DROP FUNCTION noise). - Add missing "that" to the relative clauses in the new comments. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Summary
Adds a
[triggers]section to.pgschemaignorethat matches triggers by name (glob, with negation). Ignored triggers are filtered at the inspector, so they are excluded from dump, plan generation, and drift detection alike — pgschema neither creates, drops, nor reports them.Motivation (#407)
Extensions sometimes create triggers automatically on tables you manage — e.g. the pgai vectorizer adds
_vectorizer_src_trg_*triggers to source tables. Without a way to ignore them,pgschema planflags them for drop on every run. Ignoring by name keeps the rest of the table managed while leaving those triggers out-of-band.Implementation
Mirrors the existing per-object pattern just merged for constraints (#452):
ir/ignore.go—Triggers []stringfield +ShouldIgnoreTrigger(name)ir/inspector.go— filter inbuildTriggers(skips ignored triggers before they attach to any table/view)cmd/util/ignoreloader.go—TriggerIgnoreConfigstruct +TomlConfigfield + mappingdocs/cli/ignore.mdx— new## Triggerssection using the pgai exampleTests
ir/ignore_test.goandcmd/util/ignoreloader_test.goTestIgnoreTriggers(dump + plan) — a managedproducts_set_updated_attrigger stays, while_vectorizer_src_trg_productsis excluded from dump and never flagged for dropAll unit tests, the new integration test, and
go vetpass.Fixes #407
🤖 Generated with Claude Code