[Prisma 8] `contract infer`: infer schemas other than `public` (into namespaces), keeping cross-schema foreign keys

Open
#30,805 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
postgresql, typescript
Domain
databases

Research direction

Start by reading the prisma contract infer entry point and the PostgreSQL schema introspection path; the issue names no source files or tests. Trace how the command selects public and handles foreign keys outside it, then check existing namespace and cross-namespace relation support in contracts. Done means repeatable schema selection or all-schema inference emits namespaces and preserves cross-schema foreign keys.

Written by the indexing model from the issue text.

Description

Desired behaviour

prisma contract infer reads only the public schema and has no option to choose others (--db and --output only). A database organised in several PostgreSQL schemas cannot be adopted with contract infer + db sign directly. Requested:

  • --schema <name> (repeatable) and / or --all-schemas, emitting one namespace <schema> { … } per schema;
  • foreign keys between those schemas emitted as cross-namespace relations (today a cross-schema foreign key is left out with a warning comment).

Where the gap surfaces today

Brownfield adoption (contract infer → contract emit → db sign) of a multi-schema database, although namespaces and cross-namespace relations are supported in the contract itself.

Current workaround

Infer each schema from a throw-away copy of the database in which that schema is renamed public, then compose the namespaces and add the cross-schema relations by script.

Environment

Dominant language
TypeScript
Stars
47.8k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
227

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from prisma/orm

All issues in prisma/orm

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.