Skip to content

The prisma-8 skill says a back-reference is derived automatically, but a relation declared on one side gives the other model no relation #30481

Closed

Description

@wmadden-electric

What happened

The prisma-8 skill that ships with @prisma/orm-postgres says, in skills/prisma-8/references/contract.md under "Workflow — Models, fields, relations": "Add the relation only on the owning side — the framework derives the back-reference automatically."

It does not. A relation declared only on the side that holds the foreign key gives the other model no relation at all in the emitted contract, so nothing can include the related rows from that side. An agent that follows the skill writes a contract whose queries from the other side do not exist.

Reproduction

Versions: @prisma/orm-postgres 8.0.0-rc.12 with prisma 8.0.0-rc.17-dev.124.

contract.prisma:

// use prisma-8

model Contact {
  id   String @id
  name String

  @@map("contact")
}

model Actor {
  id        String  @id
  contact   Contact @relation(fields: [contactId], references: [id])
  contactId String

  @@map("actor")
}

prisma.config.ts:

import { defineConfig } from '@prisma/orm-postgres/config';
import { definePrismaConfig } from 'prisma/config';
export default definePrismaConfig({ orm: defineConfig({ contract: './contract.prisma', db: {} }) });

Command:

pnpm exec prisma contract emit --config ./prisma.config.ts --output-path ./out

Result: the emit succeeds with no diagnostics. In out/contract.json, Actor has the relation contact, and Contact has "relations": {}.

What was expected

One of these:

  1. The contract gives Contact a derived back-reference, as the skill says.
  2. Or the skill says what the tool does: a back-reference exists only when it is declared, as a list field or an optional singular field on the other model.

The repository's own journey test reads the second way. skills/journey-tests/02a-add-relation.md expects the author to add "the back-reference posts Post[] on User" and checks that the "relation is bi-directional (forward FK + back-reference)". So the skill's sentence and the journey test disagree.

Suggested fix

If back-references are meant to be declared, correct the sentence in skills/prisma-8/references/contract.md and show the two-sided form in its example. If they are meant to be derived, that is missing, and it needs a rule for the derived field's name.

Why it matters

An application we are building on Prisma 8 added several relations to one model. Following the skill, they were declared on the owning side only, and the other side could not be queried.

Activity

  1. added a commit that references this issue on Nov 13, 2026
    61ed0da
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

    kind/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions