feat(prisma-cloud)!: deploys always run the ORM's migrate and show the ORM's own error #463
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 #463"
general
weight: 0.35
wmadden
A deploy now runs Prisma ORM's
prisma db migrate --to <ref>against every ORM database, every time, and lets the ORM decide what to do. When the ORM refuses, the user sees the ORM's whole error instead of a one-line summary.Before, a failed migration reached the user like this, with the ORM's reason and recovery steps dropped:
After, Composer writes one line saying what it ran, and the ORM's error follows in full:
(The
→line is the wording of the ORM version Composer pins today. A newer ORM release, prisma/orm#31214, rewords it; it reaches users when Composer updates the ORM.)Linked issue
TML-3726 (a failed deploy shows the ORM's own migrate error) and TML-3729 (deploys respect a database's policies). For TML-3729, a deploy now hands the ORM the ref's policies, so the ORM compares them with the database's on every deploy and refuses when they differ. A deploy never changes the database's policies itself; a person does that by hand.
Summary
Two ORM terms this change rests on
migrations/app/refs/<name>.json, usually named after an environment. It names the schema version (the "contract") that the environment's database must reach, and may declare policies: rules the database must follow, such aschange: migrate, meaning the database may change only through committed migrations. The user creates and moves refs, for example withprisma migration ref set production <migration>.@contractis the ORM's name for the schema the current commit describes. It needs no ref file.The ORM's model for continuous deployment is one command run on every deploy:
prisma db migrate --to <ref>. The ORM works out what to run, does nothing when nothing is pending, and refuses anything the database's policies forbid.What Composer did before
Composer did not follow that model. Before calling the ORM, it read the database itself to decide whether the database was already up to date, and if it judged so it skipped the ORM. When no ref was named, it migrated to the current commit's schema. That check never looked at policies, so a change to a ref's policies alone would never reach the database. To avoid silently ignoring them, Composer refused every ref that declared policies.
When the ORM did fail, Composer kept only its code and summary. For one failure, a missing migration path, it replaced the ORM's advice with its own. That advice is how an agent came to propose resetting a shared development database whose right fix was
prisma db update.What Composer does now
An app names the target on its database. It is required:
targetRefaccepts a ref name or@contract. Other forms the ORM accepts are refused when the node is declared; for example@emptywould empty the database.On every deploy and every
prisma devrebuild, Composer runs the ORM's migrate to that target and passes the ref whole, policies included. It never gives the ORM consent to change a policy. When a pull request changes a ref's policies, the next deploy fails and changes nothing until whoever administers the database applies them by hand:The next deploy then proceeds. The deploy guide says where to get the URL.
Two smaller behaviour changes come with this:
prisma deployoutput, theprisma devrebuild message, the--reportfile and the Prisma Cloud build log. It names no product. The old 1000-character limit is gone.Why services needed rewiring
A service must start only after its database is migrated. Composer used to get that order by building the connection string a service receives from the migration step's result. Composer's deploy engine treats any value built from a step that will run as possibly changed, so with the migration now running every time, every service using a database would have been redeployed on every deploy.
The connection string now comes from the database alone. The service's deployment waits for the migration through a separate setting, the same mechanism a service already uses to wait for other services it calls. An unchanged deploy redeploys nothing, on Prisma Cloud and under
prisma dev.Breaking changes
targetRef; until then it does not type-check. Then commit a ref for each environment it deploys to, withprisma migration ref set <environment> <newest migration>. The deploy guide has the steps.devneeds a committed ref before its first deploy, whentargetRefcomes from the environment name.prisma db updateinsideprisma devstops working after a schema change. Every rebuild then fails with the ORM'sMIGRATION.MARKER_MISMATCHuntil a migration is planned. The ORM refuses a database that is already at its target when no migration ends there. That is an ORM bug, tracked as TML-3999. Composer adds no check of its own to hide it, and the docs say to plan a migration for each schema change in the meantime.prisma.config.tsno longer needs a database connection. The examples used a fake address only to fill the field; it is removed.Known limit
A database that a module provisions for itself targets
@contract. Its migrations ship inside the module's package, so an app has nowhere to commit a ref for it. Such a database cannot have policies, and it moves to the module's schema in every environment when the app upgrades the package. This is recorded in the decision record and the project's deferred list.Also in this change
targetRefas above and commitmigrations/app/refs/production.json. Shared modules target@contract.targetRef), and the goals doc (the new-environment requirement above).Testing performed
- against a local Postgres: a policy mismatch that changes nothing, the manual step, a successful deploy and the new policy enforced; a new database whose ref declares policies; nothing pending; the advised command keeps
--to; an ORM refusal is not retried; a replay of the database-reset incident above;- a test that runs the real deploy engine and Prisma Cloud resources against a fake Prisma Cloud API: an unchanged deploy replaces no deployment, a first deploy starts each service after its migration, and new code replaces only its own service.
examples/orm-demo, in its own environment, destroyed afterwards: first deploy migrated, then started the service (HTTP 200); an unchanged deploy made no new service version; a ref with new policies failed as shown above and changed nothing; the--reportfile held the structured error; after the manual step, the next deploy succeeded.prisma devon orm-demo: the first run migrated and started the service; the second updated only the migration step.Checklist
Notes for the reviewer
Implementation points worth a look:
NextActionshape through the--reportfile and--jsonoutput, so a tool can tell a command from advice. Composer declares its own copy of the type, with a type test pinning it to the engine's, because@prisma/composerdoes not depend on the engine package.why, so the next actions at the end survive.{bin}placeholder in advised commands; Composer fills inprisma.Alternatives considered:
prisma deployflag. Either stays in place after the change it was meant for, so any later edit to a ref's policies would be applied on merge without anyone deciding it.production. A default either breaks an environment with no ref file, or migrates every environment to production's ref.Design and plan:
.drive/projects/deploy-runs-orm-migrate/.Agent: scully-11