Skip to content

--postgres introspection emits no FK 'references' edges (only contains/reads_from) #1746

Closed

Description

@bbqboogiedwonsen

Summary

Live PostgreSQL introspection (--postgres) produces no foreign-key references edges — only contains and reads_from. The README/docs state tables, views, functions + FK relationships are mapped.

Environment

  • graphifyy 0.9.7 (pipx, with [sql] extra + injected psycopg[binary]), Python 3.14.5, macOS (arm64)
  • PostgreSQL 15 (Supabase-hosted), connected via PG* env vars (--postgres "")

Reproduction

export PGHOST=… PGPORT=5432 PGDATABASE=postgres PGUSER=… PGPASSWORD=…
graphify extract . --postgres "" --out /tmp/pg-graph --no-cluster

Result on a schema with ~180 tables and several hundred FK constraints:

  • [graphify extract] PostgreSQL: 460 nodes, 706 edges → written graph: 460 nodes / 642 edges
  • Edge relation counts in graph.json: {'contains': 459, 'reads_from': 183} — zero references
  • Concrete example: a table with ~15 inbound FKs shows only db --contains--> plus 3 function --reads_from--> edges.

For comparison, file-based extraction of the same schema's migration .sql files does produce references edges between tables — so the gap appears specific to the live-introspection path (pg_introspect.py).

The function→table reads_from edges are genuinely useful, by the way — happy to share redacted edge stats if helpful.

Activity

  1. safishamsi commented on Jul 10, 2026

    @safishamsi
    Member

    Fixed on v8 (0.9.12), credited to @rithyKabir via #1761. The FK query now reads pg_catalog.pg_constraint instead of the privilege-filtered information_schema.referential_constraints, so a read-only --postgres role gets references edges (previously zero while tables/views appeared). Bonus: oid-based keying fixes same-named constraints on sibling tables cross-matching. Thanks for pinning it to the live-introspection path.

  2. bbqboogiedwonsen commented on Jul 11, 2026

    @bbqboogiedwonsen
    ContributorAuthor

    Perfect — thank you for the quick turnaround, and thanks to @rithyKabir for the fix via #1761.

    Reading `pg_catalog.pg_constraint` directly instead of the privilege-filtered `information_schema.referential_constraints` is exactly right: we hit this on a read-only Supabase introspection role, and the `information_schema` views silently drop rows the role doesn't own — which is why we saw zero `references` edges while tables/views/functions all came through fine. The oid-based keying fix for same-named constraints on sibling tables is a welcome bonus too; we have plenty of those.

    We'll upgrade to 0.9.12 and move our live schema graph over to the `--postgres` path. Appreciate the work! 🙏

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

Metadata

Metadata

Assignees

No one assigned

    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