Skip to content

feat: add triggers section to .pgschemaignore (#407)#453

Merged
tianzhou merged 2 commits into
mainfrom
feat/ignore-triggers-section
Jun 9, 2026
Merged

feat: add triggers section to .pgschemaignore (#407)#453
tianzhou merged 2 commits into
mainfrom
feat/ignore-triggers-section

Conversation

@tianzhou

@tianzhou tianzhou commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a [triggers] section to .pgschemaignore that 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.

[triggers]
patterns = ["_vectorizer_src_trg_*"]

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 plan flags 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.goTriggers []string field + ShouldIgnoreTrigger(name)
  • ir/inspector.go — filter in buildTriggers (skips ignored triggers before they attach to any table/view)
  • cmd/util/ignoreloader.goTriggerIgnoreConfig struct + TomlConfig field + mapping
  • docs/cli/ignore.mdx — new ## Triggers section using the pgai example

Tests

  • Unit: trigger cases in ir/ignore_test.go and cmd/util/ignoreloader_test.go
  • Integration: TestIgnoreTriggers (dump + plan) — a managed products_set_updated_at trigger stays, while _vectorizer_src_trg_products is excluded from dump and never flagged for drop

All unit tests, the new integration test, and go vet pass.

Fixes #407

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings June 9, 2026 03:23
@greptile-apps

greptile-apps Bot commented Jun 9, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds trigger-level ignore support to .pgschemaignore. The main changes are:

  • Adds a [triggers] section parsed from TOML ignore files.
  • Adds ShouldIgnoreTrigger matching with the existing glob and negation behavior.
  • Filters ignored triggers during database inspection before dump, plan, and drift comparison.
  • Documents trigger ignore patterns with the pgai vectorizer example.
  • Adds unit and integration coverage for ignored trigger behavior.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Reviews (1): Last reviewed commit: "feat: add triggers section to .pgschemai..." | Re-trigger Greptile

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread ir/inspector.go Outdated
Comment thread ir/ignore.go
Comment thread cmd/ignore_integration_test.go Outdated
Comment thread cmd/ignore_integration_test.go Outdated
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread ir/inspector.go
@tianzhou tianzhou merged commit 86079e6 into main Jun 9, 2026
2 checks passed
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.

Add [triggers] section to .pgschemaignore

2 participants