Skip to content

Add support for indexes section in .pgschemaignore#441

Open
guillaume86 wants to merge 1 commit into
pgplex:mainfrom
guillaume86:probe/ignore-indexes
Open

Add support for indexes section in .pgschemaignore#441
guillaume86 wants to merge 1 commit into
pgplex:mainfrom
guillaume86:probe/ignore-indexes

Conversation

@guillaume86
Copy link
Copy Markdown

@guillaume86 guillaume86 commented May 23, 2026

Summary

  • Adds an [indexes] section to .pgschemaignore so users can keep indexes that exist in the live database but are not declared in their schema .sql files. Without this, manually-added indexes (perf hotfixes, ad-hoc operational fixes) are flagged for drop by pgschema plan.
  • IgnoreConfig.Indexes + ShouldIgnoreIndex(name) mirror the existing per-object pattern.
  • Inspector.buildIndexes skips ignored index names before they enter the IR, so they don't appear in dump and don't show up as drift in plan.

Fixes #406

Test plan

  • Added TestIgnoreIndexes (in cmd/ignore_integration_test.go) reproducing the exact Add support for indexes to .pgschemaignore #406 scenario: a manual_perf_idx exists on a managed table, the desired schema doesn't declare it, the ignore config lists manual_*. Asserts the dump excludes it and the plan does not reference it.
  • Extended TestIgnoreConfig_AllObjectTypes and TestIgnoreConfig_NilConfig to cover indexes.
  • Extended TestLoadIgnoreFileFromPath_ValidTOML to round-trip the new [indexes] section.
  • Full suite green locally on PG 17 (go test ./... — ~7 min).

Run just the new test:

go test -v ./cmd -run TestIgnoreIndexes

🤖 Generated with Claude Code


Note (2026-05-23): pgproj (a downstream DACFX-shaped fork at https://github.com/guillaume86/pgproj) has adopted a hard-fork posture and will continue independently. This contribution remains open without expectation of merge; happy to address review feedback if a maintainer engages.

Adds a new [indexes] section to .pgschemaignore that lets users
preserve indexes which exist in the database but are not declared
in their .sql files. Without this, manually-added indexes (e.g.
perf hotfixes) are flagged for drop by `pgschema plan`.

Mirrors the existing per-object pattern: `Indexes []string` on
`IgnoreConfig` with `ShouldIgnoreIndex(name)`, an
`IndexIgnoreConfig` struct on `TomlConfig`, and a filter in
`Inspector.buildIndexes` that skips ignored index names before
they enter the IR.

Fixes pgplex#406

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 23, 2026

Greptile Summary

This PR adds ignore support for database indexes. The main changes are:

  • Adds an [indexes] section to .pgschemaignore parsing.
  • Adds IgnoreConfig.Indexes and ShouldIgnoreIndex.
  • Skips ignored indexes during database inspection.
  • Adds tests for loader parsing, nil handling, and dump/plan behavior.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The new index ignore path follows the existing object ignore pattern.
  • Constraint-backed indexes remain handled by the existing constraint flow.

Reviews (1): Last reviewed commit: "Add support for indexes section in .pgsc..." | Re-trigger Greptile

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 support for indexes to .pgschemaignore

1 participant