Add support for indexes section in .pgschemaignore#441
Open
guillaume86 wants to merge 1 commit into
Open
Conversation
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 SummaryThis PR adds ignore support for database indexes. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Reviews (1): Last reviewed commit: "Add support for indexes section in .pgsc..." | Re-trigger Greptile |
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
[indexes]section to.pgschemaignoreso users can keep indexes that exist in the live database but are not declared in their schema.sqlfiles. Without this, manually-added indexes (perf hotfixes, ad-hoc operational fixes) are flagged for drop bypgschema plan.IgnoreConfig.Indexes+ShouldIgnoreIndex(name)mirror the existing per-object pattern.Inspector.buildIndexesskips ignored index names before they enter the IR, so they don't appear indumpand don't show up as drift inplan.Fixes #406
Test plan
TestIgnoreIndexes(incmd/ignore_integration_test.go) reproducing the exact Add support for indexes to .pgschemaignore #406 scenario: amanual_perf_idxexists on a managed table, the desired schema doesn't declare it, the ignore config listsmanual_*. Asserts the dump excludes it and the plan does not reference it.TestIgnoreConfig_AllObjectTypesandTestIgnoreConfig_NilConfigto cover indexes.TestLoadIgnoreFileFromPath_ValidTOMLto round-trip the new[indexes]section.go test ./...— ~7 min).Run just the new test:
🤖 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.