Skip to content

feat: move ignore rules from .pgschemaignore to pgschema.toml - #713

Merged
tianzhou merged 4 commits into
mainfrom
feat/pgschema-toml-ignore
Nov 22, 2026
Merged

tianzhou merged 4 commits into
mainfrom
feat/pgschema-toml-ignore

Conversation

@tianzhou

Copy link
Copy Markdown
Contributor

Summary

pgschema.toml becomes the project configuration file, loaded from the current directory by dump, plan and apply. Ignore rules move into its [ignore] table, and .pgschemaignore is removed. More config blocks will follow in later PRs.

# pgschema.toml
[ignore]
schemas = ["auth"]
tables = ["temp_*", "!temp_core_*"]
privileges = ["deploy_bot"]

Breaking change

.pgschemaignore is no longer read. To migrate, move each section into a key under [ignore] and delete the old file:

.pgschemaignore (before) pgschema.toml (after)
[tables]
patterns = ["temp_*"]
[ignore]
tables = ["temp_*"]

Pattern syntax and matching are unchanged.

A leftover .pgschemaignore is a hard error with a migration hint, not a silent skip: skipping it would turn every previously ignored object into a planned change (including drops). The error also fires when a pgschema.toml sits next to it.

Changes

  • cmd/util/config.go replaces ignoreloader.go. util.LoadConfig() returns a Config whose Ignore field is the existing ir.IgnoreConfig, so the 13 per-type wrapper structs are gone. A new block is one more field on Config.
  • A half-migrated file fails instead of loading with nothing ignored: [tables] patterns = [...] at the top level is an unknown key, and [ignore.tables] is a type error. Unknown keys are rejected as before. Load errors link to the docs page.
  • Error hints in internal/diff/partition_index.go and internal/postgres/{embedded,external}.go name the new location.
  • Docs: docs/cli/ignore.mdx is rewritten with a "Migrating from .pgschemaignore" section and keeps its /cli/ignore URL. The dump, plan, apply and plan-db pages, the two comparison blog posts, and CLAUDE.md are updated to the new format.
  • There is no --config flag; the file is read from the current directory only, as .pgschemaignore was.

Test plan

  • go test ./... passes locally (all packages, embedded Postgres)
  • cmd/util/config_test.go covers the [ignore] table, missing and empty files, invalid TOML, unknown keys, both half-migrated shapes, and the leftover .pgschemaignore error
  • Existing ignore integration tests (TestIgnore*, partition index ignore tests, dump permission suite) now write pgschema.toml
  • Built the CLI and confirmed pgschema dump exits with the migration error when a .pgschemaignore is present

🤖 Generated with Claude Code

pgschema.toml is the project configuration file, loaded from the current
directory by dump, plan and apply. Ignore rules are its [ignore] table,
with one key per object type:

    [ignore]
    tables = ["temp_*", "!temp_core_*"]
    privileges = ["deploy_bot"]

The table decodes straight into ir.IgnoreConfig, so the per-type wrapper
structs of the old loader are gone. A later config block is one more
field on util.Config. Pattern syntax and matching are unchanged.

.pgschemaignore is no longer read. A leftover file is a hard error with
a migration hint rather than being skipped: skipping it would turn every
previously ignored object into a planned change. A file renamed without
rewriting its sections ([tables] patterns = [...] or [ignore.tables])
also fails, as do unknown keys.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 22, 2026 15:43
@greptile-apps

greptile-apps Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change reaches the three CLI workflows that read project ignore settings.

Fix the legacy-file lookup error path before merging so planning cannot silently lose existing exclusions.

Findings

  1. P1 Legacy rules can be skipped ▶

Summary

Moves ignore rules into the [ignore] table of pgschema.toml.

  • dump, plan, and apply now load ignore rules from pgschema.toml.

Reviews (1) · Last reviewed commit: "feat: move ignore rules from .pgschemaig..." · Reviewed by Greptile

Comment thread cmd/util/config.go Resolved

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.

🟡 Changes recommended

The legacy-file guard silently treats all os.Stat errors as absence, allowing symlink issues to bypass migration checks and potentially omit ignore rules that protect objects from planned drops.

1 open issue
What changed in this PR

This PR introduces pgschema.toml as pgschema’s project configuration file, moving ignore rules into [ignore] while preserving pattern matching behavior.

Changes:

  • Replaces the standalone ignore loader with shared configuration loading for dump, plan, and apply.
  • Rejects legacy files and invalid configuration shapes with migration guidance.
  • Updates tests, documentation, and error hints to use the new format.
File Description
testdata/​dump/​issue_472_partition_clone_trigger/​raw.sql Updates explanatory comment only.
testdata/​dump/​issue_472_partition_clone_trigger/​manifest.json Updates regression notes.
testdata/​dump/​issue_409_partitioned_fk/​raw.sql Updates explanatory comment only.
testdata/​dump/​issue_409_partitioned_fk/​manifest.json Updates regression notes.
ir/​ignore.go Documents the new configuration location; matching is unchanged.
internal/​postgres/​external.go Updates cross-schema error guidance.
internal/​postgres/​embedded.go Updates cross-schema error guidance.
internal/​postgres/​desired_state.go Updates configuration reference in a comment.
internal/​diff/​partition_index.go Updates ignore-related error hints.
docs/​cli/​plan.mdx Points planning guidance to [ignore].
docs/​cli/​plan-db.mdx Migrates cross-schema configuration examples.
docs/​cli/​ignore.mdx Documents the new format and migration steps.
docs/​cli/​dump.mdx Updates dump configuration guidance.
docs/​cli/​apply.mdx Updates apply configuration guidance.
docs/​blog/​supabase-declarative-schema-vs-pgschema.mdx Updates ignore examples and comparison text.
docs/​blog/​atlas-vs-pgschema.mdx Migrates ignore configuration examples.
cmd/​util/​ignoreloader.go Removes the legacy loader and wrapper structs.
cmd/​util/​ignoreloader_test.go Removes superseded loader tests.
cmd/​util/​config.go Adds project configuration loading and validation.
cmd/​util/​config_test.go Covers configuration parsing and migration safeguards.
cmd/​plan/​plan.go Uses the shared configuration loader.
cmd/​partition_index_migration_test.go Migrates partition migration test configuration.
cmd/​ignore_integration_test.go Migrates ignore workflow tests.
cmd/​dump/​partition_index_ignore_test.go Updates configuration fixtures and error assertions.
cmd/​dump/​dump.go Uses the shared configuration loader.
cmd/​dump/​dump_permission_integration_test.go Migrates permission-test ignore configuration.
cmd/​apply/​apply.go Loads project ignore rules for fingerprint validation.
CLAUDE.md Documents project configuration conventions.

Review effort: Balanced

Comment thread cmd/util/config.go Resolved
tianzhou and others added 2 commits November 22, 2026 07:47
The legacy-file guard used os.Stat and read every error as "no legacy
file". A dangling .pgschemaignore symlink, a symlink loop, or a
permission error on its target then let the command run without the
ignore rules.

Use os.Lstat so the entry itself is what counts, and return any lookup
error other than "not found".

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The ignore page opens with a breaking-change warning that names 1.x as
the last line to read .pgschemaignore and 2.0.0 as the release that
removes it. The CLI error for a leftover file names the version too.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

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.

🔵 Needs a closer look

A broken pgschema.toml symlink silently disables ignore rules instead of producing a load error, potentially exposing unmanaged objects to planned drops after migration.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Reject dangling pgschema.toml symlinks

cmd/​util/​config.go:66

A dangling pgschema.toml symlink is treated as a missing optional file: os.Stat returns ENOENT, so the loader succeeds with Ignore == nil. After migration, when .pgschemaignore has been deleted, losing the symlink target therefore silently disables all ignore rules and can expose unmanaged objects to planned drops. Use os.Lstat for this existence check so an existing but broken config symlink reaches DecodeFile and produces a load error.

1 resolved since last review

Review effort: Balanced

os.Stat reports a symlink with a missing target as "not found", so the
loader took it for an absent optional file and returned an empty config
with nothing ignored.

Check the entry with os.Lstat instead. A dangling symlink then reaches
the decode step and fails there with the file path.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@tianzhou
tianzhou merged commit c3a65ce into main Nov 22, 2026
1 check 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.

2 participants