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
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
wmadden-electric
Prisma Composer is the tool behind
prisma devandprisma 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(...)
bashnpx 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"
`
prisma contract emitThe 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
, runprisma migration planto write a migration, then letprisma devor a deploy apply it. In Composer0.40.0the first pass works, but the second fails.prisma migration planstops withMIGRATION.PLAN_ORIGIN_UNKNOWN, and a runningprisma devnever picks up the new migration.apps/docs/AGENTS.mdThe 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
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.compute()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
,postgres()andrawPostgres().composer/databases.mdx4. The Composer landing page linked 7 of its 14 subpages.
What changes, gap by gap
1. The HTTP example is a new section on
. It is a one-service app with every file written out: the schema,prisma.config.ts, the service declaration, a Bunfetchhandler, and the root module (the app's top-levelmodule.ts), which also gives the service a public URL. Then come the build, theprisma devoutput and thecurlcalls. It sits on the Databases page because Getting started deliberately has no database.databases.mdx2. How migrations are applied is a new section on
, plus a short "Databases and migrations" section oncomposer/local-development.mdx. Composer has two kinds of database:postgres()- A
database has tables that Prisma ORM manages from a schema.prisma devapplies its committedmigrations/each time it starts, and a deploy applies them before the services start.rawPostgres()- A
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).composer/api-reference.mdx3. Signatures are on a new page,
, under Reference. It covers every option ofcompute(),rawPostgres(),postgres()anddataContract(), 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.composer/index.mdx4. The landing page,
, now links all 14 subpages in groups, one line each.cli/deploy.mdxTwo smaller fixes ride along, because they are on the same pages:
gets a section forprisma 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, therawPostgres()example's database address wasmy-app.auth.database. The example provisions the database in the root module, not inside anauthModule, so the address ismy-app.database.prisma devComposer 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.
applies migrations but never moves the Prisma ORM'sdbref, the file that records which migration the development database is at. With nodbref, the secondprisma migration plancannot tell where to start. This blocks the held passage.prisma dev2. A running
rebuilds whencontract.jsonchanges, but does not pick up the migration planned right after it. This also blocks the held passage.prisma dev3. When
refuses a schema with no migration, its message advisesprisma db update, but the faileddevhas already stopped the database.postgres({ config })4. Composer's guide says the
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.prisma dev5.
's local Postgres shares one session across connections, so a Bun SQL pool with prepared statements fails after a reconnect. A paragraph ondatabases.mdx, on main since October, tells readers to setprepare: 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.wip/composer-gaps/held-schema-change.mdThe held passages and their restore notes are in the branch's working folder (
, 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.An agent built the example app with Composer 0.40.0How it was checked
,prisma8.0.0-rc.36and@prisma/orm-postgres8.0.0-rc.25, and ran it underprisma dev:POSTreturned 201 andGETreturned the rows, and bad requests gave 400, 404 and 405.
Every new code sample was type-checked with tscagainst 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.0and 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.prisma deploy listNot run: anything that needs a deployed app. So
,prisma postgres connection create, and the claim that a deploy applies migrations before the services start rest on the source, not on a run.Document prisma migration plan --from <migration>Alternatives considered
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 devand a deploy apply, and therawPostgres()` part all work today, and gap 2 needs them for the release.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 -->