← Back to Pull requests

docs(composer): a runnable HTTP API example with a database, how migrations are applied, and an API reference; the second-migration loop is held until Composer fixes it #8965

Closed
unknown closed this pull request without merging on Nov 30, 2026 07:05 UTC
View on GitHub
unknown unknown commented on Nov 30, 2026 05:49 UTC
Author

Prisma Composer is the tool behind prisma dev and prisma deploy. An app declares its services and databases in TypeScript, and Composer runs them on your machine and deploys them to Prisma Compute. This pull request fills four gaps in the Composer docs. Its main piece is a complete example of an HTTP service backed by a database table, which a reader can build and run from an empty folder:

``ts title="src/server.ts (excerpt)"
import service from './service.ts';

const { db } = service.load(); // the dependencies Composer wired to this service
const quotes = db.client.orm.public.Quote; // the typed Prisma ORM client for the Quote table

// GET /quotes returns quotes.all(); POST /quotes calls quotes.create(...)


bash
npx prisma contract emit # schema file -> contract.json and contract.d.ts
npx prisma migration plan --name init # writes the first migration to migrations/
npm run build && npx prisma dev # local Postgres, apply migrations/, start the service
url=$(npx prisma dev url quotes-app.quotes) # the service's address is <app>.<service>
curl -X POST "$url/quotes" -H 'content-type: application/json' -d '{"text":"Make it work, make it right, make it fast."}'
curl "$url/quotes"
`

The decision: document the loop that works today, hold back the one that doesn't

A Composer app changes its database in a loop: edit the schema, run prisma contract emit, run prisma migration plan to write a migration, then let prisma dev or a deploy apply it. In Composer 0.40.0 the first pass works, but the second fails. prisma migration plan stops with MIGRATION.PLAN_ORIGIN_UNKNOWN, and a running prisma dev never picks up the new migration.

The pages show the first pass, which is all the example needs. They do not say the loop can be repeated, and the "Change the schema" passage is held back until a Composer release fixes it. They also carry no workaround and no warning. The docs rules in apps/docs/AGENTS.md say a defect in a Prisma tool is fixed in the tool, never stepped around on a page, because a workaround tells every reader we know the product is broken and stays on the page after the fix.

Why these pages

We run an agent that builds a small app using only our docs (the getting-started eval), and record where it gets stuck. The Prisma 8 general-availability plan requires the four Composer gaps it found to be closed:

1. No example of a plain HTTP service with GET and POST routes.
2. No page says how migrations reach a database, locally or on deploy.
3. No full signatures for
compute(), postgres() and rawPostgres().
4. The Composer landing page linked 7 of its 14 subpages.

What changes, gap by gap

1. The HTTP example is a new section on composer/databases.mdx. It is a one-service app with every file written out: the schema, prisma.config.ts, the service declaration, a Bun fetch handler, and the root module (the app's top-level module.ts), which also gives the service a public URL. Then come the build, the prisma dev output and the curl calls. It sits on the Databases page because Getting started deliberately has no database.
2. How migrations are applied is a new section on
databases.mdx, plus a short "Databases and migrations" section on composer/local-development.mdx. Composer has two kinds of database:
- A
postgres() database has tables that Prisma ORM manages from a schema. prisma dev applies its committed migrations/ each time it starts, and a deploy applies them before the services start.
- A
rawPostgres() database is a bare Postgres database that Composer never changes. The section shows how to get its connection string locally (prisma dev url) and when deployed (prisma postgres connection create).
3. Signatures are on a new page,
composer/api-reference.mdx, under Reference. It covers every option of compute(), rawPostgres(), postgres() and dataContract(), the helper that wraps the emitted schema files for Composer. For each option it gives the type, whether it is required, the default and what the call returns, and each function has an example.
4. The landing page,
composer/index.mdx, now links all 14 subpages in groups, one line each.

Two smaller fixes ride along, because they are on the same pages:

  • cli/deploy.mdx gets a section for prisma deploy list, which lists what an app has deployed. The command exists, and the CLI error reference mentions it, but it had no section.

  • On databases.mdx, the rawPostgres() example's database address was my-app.auth.database. The example provisions the database in the root module, not inside an auth Module, so the address is my-app.database.
  • Composer defects found

    Five, with reproductions or source references, written up for filing as issues in prisma/composer. The automated permission check stopped this session from opening them, so they are with Will to file:

    1. prisma dev applies migrations but never moves the Prisma ORM's db ref, the file that records which migration the development database is at. With no db ref, the second prisma migration plan cannot tell where to start. This blocks the held passage.
    2. A running
    prisma dev rebuilds when contract.json changes, but does not pick up the migration planned right after it. This also blocks the held passage.
    3. When
    prisma dev refuses a schema with no migration, its message advises prisma db update, but the failed dev has already stopped the database.
    4. Composer's guide says the
    postgres({ config }) path is relative to the module file, but the code resolves it from the working directory. The pages state no rule until Composer settles which one it means.
    5.
    prisma dev's local Postgres shares one session across connections, so a Bun SQL pool with prepared statements fails after a reconnect. A paragraph on databases.mdx, on main since October, tells readers to set prepare: false. That is a workaround, and it is to be removed when this is fixed. This pull request does not repeat or link to it.

    The held passages and their restore notes are in the branch's working folder (wip/composer-gaps/held-schema-change.md, which git ignores). They go back in with the Composer release that fixes defects 1 and 2, after the loop is run again against it.

    How it was checked

  • An agent built the example app with Composer 0.40.0, prisma 8.0.0-rc.36 and @prisma/orm-postgres 8.0.0-rc.25, and ran it under prisma dev: POST returned 201 and GET returned the rows, and bad requests gave 400, 404 and 405.

  • Every new code sample was type-checked with tsc against those packages, by hand, not in CI.

  • A second agent, which did not write the pages, compared every claim with Composer's source at v0.40.0 and the published type declarations, in two rounds. Its findings are fixed.

  • Four rounds of fresh-reader review; their marks are fixed.

  • pnpm lint:links (internal links and anchors) passes.
  • Not run: anything that needs a deployed app. So prisma deploy list, prisma postgres connection create, and the claim that a deploy applies migrations before the services start rest on the source, not on a run.

    Alternatives considered

  • Document prisma migration plan --from <migration> for the second pass. It names the starting point by hand, and it works today. Readers would get a working loop now, but the page would carry a workaround for defect 1, and it would stay after the fix.

  • Add a known-issue note to the loop. It is honest, but it is a warning about our own defect on a public page. The docs rules forbid that for the same reason: the fix belongs in Composer, and the note outlives it.

  • Hold the whole migrations section until the fix ships. The first migration, what dev and a deploy apply, and the rawPostgres()` part all work today, and gap 2 needs them for the release.

  • Give the HTTP example a page of its own. It relies on the database concepts on the Databases page, so it stays next to them.

  • Generate the API reference from the type declarations. It would stay accurate on its own, but this docs site has no generator for Composer, and the types do not say what each option does.
  • Agent: actaeon-80

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Documentation
    Added a Composer API reference covering core APIs, options, return values, and service and database setup.
    Expanded database guides with migration workflows, local development behavior, and a complete example app.
    Added a CLI reference for listing deployments, including output formats, flags, and error behavior.
    * Clarified storage capabilities, Composer concepts, and documentation navigation.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: wmadden-electric Review duration: 75m
    All Vouch review confidence checks passed
    Residual risk 0.33 = Change Risk (0.75) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.75 · 650 lines diff across 8 files
    0.75
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.075
    Real PR Conversation Timeline
    1 comments
    "Review active on #8965"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 75.2% (HIGH) · Higher = larger blast radius
    75.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 32.5% · Safe to merge
    32.5%
    Repository