[Prisma 8] `contract infer`: model a partitioned table once, skip its partitions

Open
#30,806 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
57/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
node.js, postgresql, typescript
Domain
backend, databases

Research direction

Start by tracing the contract infer database introspection path and how it handles PostgreSQL table metadata, especially pg_class.relispartition. Check how inferred foreign keys create back-relations, then see how db verify --strict determines whether database elements are claimed. Done means parent tables are modeled once, their partitions do not create duplicate models or relations, and any chosen strict verification behavior is covered.

Written by the indexing model from the issue text.

Description

Desired behaviour

For a declaratively partitioned table (PARTITION BY RANGE, e.g. monthly partitions managed by pg_partman), contract infer emits the parent AND every partition (event_p20260101, …, event_default) as separate models; each partition also repeats the parent's foreign keys, so every referenced model gains one back-relation per partition. Requested: skip partition children (pg_class.relispartition) and model only the partitioned parent, with its foreign keys once. Optionally let db verify --strict treat partitions of a declared parent as claimed (today they are reported as unclaimed elements).

Where the gap surfaces today

Adopting a database that uses partitioning for large append-only tables; partitions come and go monthly, so the inferred contract changes every month.

Current workaround

Post-process the inferred PSL to drop the partition models and their back-relations; db verify without --strict.

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.