feat: add --ignore-schema to exclude schemas from the diff - #175
Merged
Conversation
Apakottur
force-pushed
the
feat/ignore-schema
branch
from
July 20, 2026 10:38
6fe73be to
1d079b3
Compare
Exclude named schemas from the diff entirely: run_introspection_query drops their rows for every LOAD query, so no create/drop of the schema or its objects is emitted. A schema connected to a kept schema by any dependency is refused up front (schema_connections), since ignoring a non-isolated schema would emit a migration that fails at apply. Filtering is driven by the query's kind: LOAD queries are filtered, GUARD queries are not. So an unsupported object or invalid index in an ignored schema still refuses the run -- --ignore-schema excludes objects from the diff, it does not silence a database pgmig cannot process. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vc8vdq3jNTBHg3TfV6L7BD
Apakottur
force-pushed
the
feat/ignore-schema
branch
from
July 20, 2026 11:56
1d079b3 to
38b2084
Compare
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.
What
A new repeatable flag
--ignore-schema(library paramignore_schemas: Sequence[str]) that excludes named schemas from the diff entirely — their tables and every other object, and theCREATE/DROPof the schema itself, are ignored. This includes object kinds pgmig cannot otherwise process (e.g. a rule or an invalid index in an ignored schema no longer blocks the run).Details
Implemented at the introspection boundary, so the diff layer is untouched — ignored objects simply never exist in the model:
unsupported,invalid_indexes,matview_dependencies) read the ignore set from the introspection context and skip findings in ignored schemas, so an unsupported/invalid object in one does not raise.introspect_dbprunes the assembledDbIntrospectionResultof every ignored schema and all references to it, after the loaders run (they share queries with cross-schema dependency edges, so pruning is applied once to the finished model):schema_by_name, extensions installed into those schemas, the view / matview / view-column / composite-type / enum-column dependency maps (by key and by value), and schema-scoped default-privilege rules. Empty ignore set → no-op early return.agenerate/generateand the CLI.--ignore-schema extextschema + its objectsextschema + its objectsext.tdiffers;public.tnewCREATE TABLE public.texthas a rule / invalid indexPgmigUnsupportedErrorNotes