Add --skip-not-implemented flag to gracefully handle unimplemented diffs#290
Open
braden-vh wants to merge 2 commits into
Open
Add --skip-not-implemented flag to gracefully handle unimplemented diffs#290braden-vh wants to merge 2 commits into
braden-vh wants to merge 2 commits into
Conversation
Adds a `WithSkipNotImplemented()` PlanOpt and a corresponding `--skip-not-implemented` CLI flag. When enabled, any diff operation that returns `ErrNotImplemented` is silently skipped rather than failing the entire plan, enabling best-effort diffing of schemas that contain features pg-schema-diff does not yet fully support. The check is handled in `generatePartialGraph`, the single choke point through which all `Add`, `Delete`, and `Alter` operations flow, so no per-generator changes are needed.
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
WithSkipNotImplemented()PlanOptand a corresponding--skip-not-implementedCLI flag.When enabled, any diff operation that returns
ErrNotImplementedis silently skipped rather than failing the entire plan. This enables best-effort diffing of schemas that contain features pg-schema-diff does not yet fully support (e.g. privileges on partition tables, deleting partitions without dropping the parent).Motivation
Several real-world schemas trigger
ErrNotImplementedduring plan generation — particularly around partitioned tables — making schema drift detection entirely unusable even when the unimplemented operations represent a small fraction of the diff. This flag provides an escape hatch while the underlying features are being implemented.Changes
pkg/diff/plan_generator.go— addsskipNotImplemented booltoplanOptionsand exportsWithSkipNotImplemented() PlanOptpkg/diff/sql_vertex_generator.go—generatePartialGraphchecksskipNotImplementedand skips rather than errors onErrNotImplementedin all three loops (adds, deletes, alters)pkg/diff/sql_generator.go— threadsskipNotImplementedthroughschemaSQLGeneratorandtableSQLVertexGeneratorto allgeneratePartialGraphcall sitescmd/pg-schema-diff/plan_cmd.go— wires up--skip-not-implementedflag