Skip to content

capture-time schema filtering (--schema flag and [capture] config) #22

Description

@nandorholozsnyak

Problem

All capture commands (dump-schema, init, snapshot take, snapshot activity) introspect every user schema in the database. There's no way to restrict capture to specific schemas.

Our use case: we have a schema with no PII and a public schema containing personal data (emails, names). We want to use dryrun's offline MCP capabilities but can't commit the snapshot to our repo because it includes public schema objects.

Post-load filtering exists in MCP tools (schema parameter on list_tables, describe_table, etc.) and the lint --schema flag, but PII has already hit disk at that point.

Proposal

Include-list filtering at capture time, configurable via CLI flag and dryrun.toml:

dryrun dump-schema --schema inventory
dryrun init --schema inventory
dryrun snapshot take --schema inventory
[capture]
schemas = ["inventory"]
  • CLI --schema (comma-separated) overrides config
  • Empty/absent list = capture all (backward compatible)
  • Filtering applied after introspection, before any disk write (JSON, history.db)
  • Must filter all three streams: DDL, planner stats, activity stats

Notes

  • SQL queries in internal/schema/sql/ use //go:embed through QueryStore — Go-level post-query filtering before serialization is lower churn than parameterizing every SQL file, and achieves the same PII guarantee
  • search_path in the connection URL doesn't help — introspection queries hit pg_catalog directly, bypassing search_path
  • Cross-schema FKs: FK metadata on included tables should be kept even if the referenced table's schema is excluded (the constraint text is string-based)
  • Non-existent schema in filter: not an error, just zero objects matched — a stderr warning would be helpful

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions