Deploying and operating
prisma deploy takes your entry file (the one whose default export is the app's root, built with appRoot()) and stands the whole app up on Prisma Cloud. To remove the app with every environment, delete its Project with prisma project delete. To remove one environment, call the destroy operation from @prisma/composer/control in a script (see Removing an app or an environment). Which environment you're touching — production, staging, a preview such as pr-42 — is always your choice when you run it, never something in your code.
| You want to… | Run |
|---|---|
| Deploy to production | prisma deploy |
| Deploy another environment | prisma deploy --environment <name> |
| Deploy under a different app name | prisma deploy --name demo-42 |
| See what is deployed in an environment | prisma deploy list --environment <name> (see Listing what is deployed) |
| Remove the app and every environment | prisma project delete <id> --confirm <id> (see Removing an app or an environment) |
| Remove one environment | the destroy operation (see Removing an app or an environment) |
Credentials
The prisma commands and the operations you call from a script sign in
differently:
prisma deploysigns in the way everyprismacommand does. On your machine, runprisma auth loginonce; it opens a browser and stores a session for one workspace. In CI, setPRISMA_SERVICE_TOKENinstead; it overrides any stored session.prisma devneeds no sign-in.- The operations of
@prisma/composer/control, and so a destroy script, never use aprisma auth loginsession.deployanddestroyread two environment variables, and each is required once the operation reaches Prisma Cloud:PRISMA_SERVICE_TOKEN, a service token you create in the workspace's settings in the Prisma Console, andPRISMA_WORKSPACE_ID, the workspace's id, shown in the same settings.devandlogread neither, because they never reach the platform.
The first deploy of an app also needs a region, because it creates the app's Project in Prisma Cloud. Set the environment variable PRISMA_REGION to a region id, such as us-east-1, or pass it in prisma.config.ts as prismaCloud({ region: 'us-east-1' }); the option wins over the variable. Without either, that deploy stops with "no deploy region is configured". Prisma Cloud refuses an id it does not know when it creates the Project; in prisma.config.ts the type check refuses it first. Only the first deploy needs a region. When one is set, every deploy also creates the app's services and databases in it; when none is set, they take the Project's region. Do not change the region after the first deploy: a database in another region than the one set is replaced by a new, empty database, and a service's deploy fails, because a service cannot move region. prisma dev needs no region.
A fresh checkout with credentials in place, and a region for the first deploy, deploys successfully: the CLI finds or creates everything else. Keep token values out of the repo (an .env you source at deploy time, or CI secrets).
Runtime
The prisma bin starts under Node. prisma deploy and prisma dev load the
entry module (module.ts here) and every module it imports, so those modules decide the runtime
prisma needs. Run it with your package manager by default:
pnpm prisma deploy or npx prisma deploy.
prisma deploy and prisma dev run Alchemy inside the prisma process, and the destroy operation runs it inside the process that calls it. So Alchemy runs under whatever your modules run under, and the invocation decides that:
| Invocation | prisma runs under |
|---|---|
pnpm prisma … or npx prisma … |
Node |
bunx prisma … |
Node (the bin's node shebang) |
bunx --bun prisma … |
Bun |
bun node_modules/prisma/dist/prisma.js … |
Bun |
If your modules use Bun APIs (they import bun, or call Bun.serve when imported), prisma must run under Bun:
bun node_modules/prisma/dist/prisma.js deploy
bun node_modules/.bin/prisma does not run with pnpm, where that file is a
shell script. The examples in the prisma/composer repository run prisma
under Bun, which is why their scripts start with bun.
Configuration
Composer reads its configuration from the composer section of
prisma.config.ts and nowhere else:
// prisma.config.ts
import { defineConfig as composer } from '@prisma/composer/config';
import { nodeBuild } from '@prisma/composer/node/control';
import { prismaCloud, prismaState } from '@prisma/composer-prisma-cloud/control';
import { definePrismaConfig } from 'prisma/config';
export default definePrismaConfig({
composer: composer({
entry: './module.ts',
extensions: [prismaCloud(), nodeBuild()],
state: prismaState(),
}),
});
The commands look for prisma.config.ts in the directory you run them from
and in its parent directories up to the repository root, and each file may
declare its own composer section. The nearest file that declares one wins,
and its section is used whole: a composer section is never merged key by key
with one further up. The deploy imports that file again while it runs, so keep
the section in the file itself rather than building it somewhere the file
cannot reach.
entry is the module whose default export is your app's root, built with appRoot(). It is relative to prisma.config.ts, so prisma deploy finds it from any directory below that file. --entry <path> on prisma deploy or prisma dev replaces it for one run, relative to the directory you run the command in. With neither, the command stops with CONFIG.ENTRY_MISSING before doing any work.
prisma dev keeps its local state, the record of which local service,
database and bucket backs each node, in the directory it runs in. Run
prisma dev, prisma dev url and prisma dev stop from the same directory
each time, normally the one that holds prisma.config.ts. Run from another
directory, prisma dev starts a second, empty local copy of the app.
Upgrading from a version that took the entry as an argument. prisma deploy module.ts and prisma dev module.ts now fail with
CLI.INVALID_ARGUMENTS: "Too many arguments, expected 0 but encountered
"module.ts"". Add entry: './module.ts' to the composer section of
prisma.config.ts and run prisma deploy, or pass --entry module.ts.
Before a command runs, the section is checked: entry, when set, must be a
non-empty path, extensions a list of extension descriptors with distinct
ids, and state a state descriptor. Any other key is an error. The
descriptors reach the deploy exactly as your file built them.
Earlier versions read a separate prisma-composer.config.ts. That file is no
longer read, and the commands refuse the old setup rather than ignore it:
| Diagnostic | When |
|---|---|
CONFIG.SECTION_MISSING |
No loaded prisma.config.ts declares a composer section, including when there is no prisma.config.ts at all. |
CONFIG.FIELD_RETIRED |
The section still has configPath, which pointed at the old file. |
CONFIG.FILE_RETIRED |
A prisma-composer.config.{ts,mts,mjs,js} sits next to the prisma.config.ts that declares the section. |
All three appear under the Prisma CLI's own CLI.CONFIG_SECTION_INVALID
headline. SECTION_MISSING is fixed by adding composer: composer({ ... }) to
prisma.config.ts. FIELD_RETIRED and FILE_RETIRED are fixed by moving the
old file's extensions and state into that section, then removing
configPath or deleting the old file. Nothing migrates it for you.
If you mount Composer's commands into your own CLI through
@prisma/composer-cli/family, note that the ComposerSection type is gone: the
section's value is PrismaAppConfig, exported from @prisma/composer/config.
Build first
Composer runs the alchemy that your app's @prisma/composer depends on: it
finds that package beside @prisma/composer and starts its entry with Node (Runtime says
when Alchemy then moves to Bun). Your app does not need alchemy as a direct
dependency, and no node_modules/.bin/alchemy link is needed on any platform.
prisma deploy does not build for you — it assembles what your
build produced:
turbo run build && prisma deploy
Deploy state (what's already provisioned, so re-deploys diff instead of recreate) is stored with the environment it describes, not on your machine — that's the state: prismaState() line in the composer section of prisma.config.ts. The platform hosts each environment's state behind its API, scoped to that environment's Branch inside the app's Project; nothing extra shows up in the Console. Everyone deploying the app shares it, your laptop and CI see the same world, and two concurrent deploys of the same environment lock each other out instead of corrupting it: while one holds the deploy lease, the second fails immediately with a message naming the holder. If a deploy crashes, its lease expires (about a minute) and the next deploy takes over; a run that outlives its lease has every state operation rejected by the platform, so it can't corrupt the takeover's state. State lives and dies with its environment: deleting an environment's Branch — or the whole Project — removes that environment's state with it (production's state lifetime is spelled out under Destroying below).
Environments
An environment is a place the app runs, and every environment has a name.
You choose it with --environment when you deploy. Without the flag,
prisma deploy deploys the environment production, exactly as
--environment production does. Each environment is a complete, isolated copy
of the app — every service, every database, its own configuration. Nothing is
shared between environments except the code:
prisma deploy # production
prisma deploy --environment staging # a persistent staging environment
prisma deploy --environment pr-42 # one environment per PR
On Prisma Cloud, the app is a Project (named after your root module) and an
environment is a Branch of it. production is the Project's default Branch.
Any other name is the Branch whose gitName is that name, created on the
first deploy if it does not exist. A name that is the default Branch's own
name, such as main, is refused: it would be production under a second name.
Deploy production as production, or with no flag.
Re-deploying any environment is idempotent — it updates the resources in
place. An environment name must be a valid git ref name
(git check-ref-format); an invalid name fails with
DEPLOY.ENVIRONMENT_INVALID, never a silent rename.
Every node has an address: the app name, then the path of provision ids
down to the node (storefront-auth.auth.database).
Piped, prisma deploy writes one line per deployed entity with four tab-separated fields: the node's address, the entity kind, the entity id and its URL, which is empty for an entity without one. On Prisma Cloud the entity kind is compute-service, postgres-database or bucket. For example, prisma deploy | cut -f4 prints each entity's URL, or an empty line for one without. Everything else the deploy prints, including Alchemy's progress, goes to stderr. Piped output gives the rules every data line follows.
Two successful deploys print fewer lines than you might expect. A node that published no entities, such as S3 credentials, gets no line. A deploy whose run wrote no report prints no lines at all. Both exit 0. A script that must tell these apart from a deploy with nothing in it uses --json: its summary lists every node, including those without entities, and is null when the run wrote no report.
Services, managed Postgres databases and buckets record their address as
logicalId on their Branch. Console uses the same address
in the topology to find each resource and its counterpart on main. The row on a
Branch that holds a node's address is that node's resource: if a deploy is
interrupted after a resource was created but before it was recorded, the next
deploy finds the resource by its address and carries on. Destroy does not do
this: after an interrupted production deploy, deploy once more before destroying,
or the half-created resource is left behind. Existing environments
receive the address on their next deploy, without replacing the resource. Local
dev creates no platform rows.
The address is the identity, so changing it makes a different entity. Renaming
a node that has no explicit provision id, changing its id, or moving it into
another module creates new rows and deletes the old ones on the next deploy; for
a database or a bucket, that deletes its data. Renaming a resource in the
Console changes nothing.
Compute deployments capture their environment when they are created. Composer
waits for its environment-variable updates to finish before creating a
deployment. Later variable updates do not change an already-created
deployment's environment. A service's input document is not an environment
variable: the deploy writes it into the service's artifact, in
compute.bootstrap.json, so it is not limited to a variable's 8 KB, and changing it gives the
service a new artifact and a new deployment.
After a deploy, each service is a Compute service in the Project; its public URL is its service endpoint domain — printed when the deploy finishes, and also shown in the Console.
The graph is the same in every environment; only configuration may differ.
To compute a value from the environment's name, use resolve() over
environment.name, as Values that differ per environment
describes.
What a deploy prints
While it runs, a deploy prints each step as it starts and when it finishes, with how long it took:
▸ load config and app
✔ load config and app (1.1s)
▸ assemble services
▸ assemble web
✔ assemble web (3m 42s)
✔ assemble services (3m 42s)
▸ connect to project and branch
✔ connect to project and branch (2.0s)
▸ check environment variables
✔ check environment variables (38.2s)
▸ plan and apply
✔ plan and apply (1m 31s)
▸ record result
✔ record result (10.3s)
web: https://uvw.ewr.prisma.build
✔ Deployed storefront-auth to production in 6m 5s.
Assembling is one step per service. A Node service with
dependencies: 'external' can take minutes here, because its runtime
dependencies are traced and copied into the deploy artifact (see
Building an app § Builds).
Inside plan and apply, each resource the deploy engine creates, updates or deletes is a step of its own, such as ▸ creating storefront-auth.web and ✔ created storefront-auth.web (12.0s), and the engine's log lines print between them.
The last line is the whole deploy, from start to finish.
With --json, each step is a step-started and a step-finished line on stdout, followed by an endpoint line per public URL and the result line. A step-finished line carries data.durationMs. An assemble step's data also holds whatever the service's build adapter reports, and the check environment variables step's data holds checked and unset, how many platform variables it checked and how many have no value. When some have no value and no service needs them, a message line follows the step, whose data.unset lists each one with its readers and commands (Platform variables). The build adapter's fields vary by adapter, so read them as information, not as a stable format. The result line has the deploy's total durationMs beside summary, whose findings.unset lists the platform variables with no value again.
A deploy ends by printing your app's own topology — the names you authored, what each one became on the platform, and the public URLs:
storefront-auth
├─ auth
│ └─ api compute-service cps_abc123
│ https://xyz.ewr.prisma.build
├─ db postgres-database db_def456
└─ web compute-service cps_ghi789
https://uvw.ewr.prisma.build
The tree is your module structure: storefront-auth.auth.api is the api
service inside the auth module. Under each name is the platform resource it became and its id
— the thing to search for in the Console when you need it.
A URL appears only where the address is genuinely public. A Compute
service prints one because its endpoint is reachable. A database never does:
it has a connection string, not a public endpoint, and printing it in a
terminal would be the wrong thing in both directions. Nothing that reports a
URL here is a secret, and nothing secret is reported here at all — an
s3-credentials node, whose whole product is a key pair, prints no resource
line for that reason.
A node that deployed but published nothing reportable is still listed, marked
(no entities reported), so a node is never silently missing from the tree.
If you're wondering where the JSON went: deploys used to end with a raw
{ outputs: {} } blob from the underlying deploy engine — always empty, never
about your app. It's gone, replaced by the tree above. Nothing you can
configure printed it and nothing depended on it.
Platform variables
A platform variable is a variable on Prisma Cloud that a service reads by name at boot. Your app root declares each one with a node, variable({ name }) for a plain value or variable.secret({ name }) for a secret, and passes its value to the services that read it (Building an app § Platform variables):
export default appRoot('shop', ({ provision }) => {
const apiKey = provision(variable.secret({ name: 'EMAIL_API_KEY' }));
provision(emailService, { input: { apiKey } });
});
You set its value on the platform as text. A variable declared with a schema, such as variable({ name: 'SMTP_PORT', schema: type('number') }), is decoded and validated when the service boots, not when you deploy: a text that does not fit fails the service at boot, the deploy still succeeds, and the error is in prisma service logs <service> (Building an app § A typed platform variable). The node creates nothing: the deploy report has no line for it. The deploy does not copy a value from .env or your shell to the platform, because that could push a local value into a remote environment by accident, and today it creates, changes and deletes no platform variable.
Set a variable with the prisma CLI, at one of three scopes:
# production
prisma project env add 'EMAIL_API_KEY=<value>' --project '<project id>' --role production
# every preview environment
prisma project env add 'EMAIL_API_KEY=<value>' --project '<project id>' --role preview
# one preview environment only, overriding the preview-wide value
prisma project env add 'EMAIL_API_KEY=<value>' --project '<project id>' --branch 'staging'
update, list and delete take the same flags. A deployment receives every variable of its class with its own branch's overrides on top, so a preview-wide value reaches every new preview environment.
The platform copies the variables into a deployment when it creates it. A value you change reaches a service at its next deploy, and that deploy replaces exactly the services that read the variable.
What the deploy checks
The check environment variables step looks up every platform variable the app reads, before any service or database is created. It reads whether a value exists, never the value.
-
A variable a service needs that has no value fails the deploy. Whether a service needs it is decided by the service's input schema: the deploy leaves the variable out and validates the input. A required field fails; an optional one does not.
Deploy failed. 1 platform variable a service needs has no value: - EMAIL_API_KEY (read by service "shop.email", field "apiKey") Set it on the platform, then deploy again: - prisma project env add 'EMAIL_API_KEY=<value>' --project 'proj_…' --role preview - prisma project env add 'EMAIL_API_KEY=<value>' --project 'proj_…' --branch 'staging'For
productionthe command uses--role production. For any other environment the preview-wide command comes first, so that the next preview environment has the value too. -
A variable nothing needs that has no value is listed, and the deploy goes on. The list prints right after the step, and again at the end of the deploy output:
✔ check environment variables (1.2s) Platform variables with no value: - STRIPE_WEBHOOK_SECRET (read by service "shop.billing", field "webhookSecret") prisma project env add 'STRIPE_WEBHOOK_SECRET=<value>' --project 'proj_…' --role productionThe service starts without that field, and its schema decides what that means. A platform variable node that no service reads is listed the same way, once, named by its node:
named by resource "shop.emailFrom", read by no service. That includes a secret that a module receives and passes to no service. -
A variable Prisma Cloud manages itself (
isManagedBySystem) fails the deploy, naming it. Rename it in your app.
A new app's first deploy creates its project, then stops at this step if a service needs a variable, with the commands and the new project id. Set the variables and deploy again.
At boot, an unset or empty variable leaves its field out of the service's input, and the service's schema decides. A service whose schema refuses the input fails at boot, and the error ends with the names of the variables that had no value. Prisma Cloud still reports a service that fails at boot as running, and the deploy promotes it, so the deploy succeeds; the error is in prisma service logs <service> --project <project id>.
Every deployment on Prisma Cloud receives every variable of its class, including the ones another service reads. Under prisma dev each service receives only its own.
Names
A name is an upper-case letter followed by upper-case letters, digits and underscores, such as STRIPE_SECRET_KEY. These names are reserved: any name starting with COMPOSER_, DATABASE_URL, DATABASE_URL_POOLED, PORT, PATH and HOME. Each name is declared by one node: two nodes with one name fail, naming both addresses. A name has one meaning in an app: a platform variable and a field X of your root's input cannot share it. Each of these fails before anything is created, naming the variable and both places.
Listing what is deployed
prisma deploy list shows every node the app has deployed in an environment,
the platform ID each one deployed to and, for a service, its URL. It reads the
environment on Prisma Cloud, so it works from any machine and does not need the
terminal that ran the deploy:
$ prisma deploy list --environment pr-42
Address Kind Platform ID URL
storefront-auth project proj_avmiqutogcve9ojwdfb8l28z
storefront-auth.auth module
storefront-auth.auth.database postgres db_p93c9pzn1k75bdmbgtuazav4
storefront-auth.auth.service service cps_p2wu05hfr90sknm62mk4n1ke https://p2wu05hfr90sknm62mk4n1ke.ewr.prisma.build
storefront-auth.storefront service cps_uihnu0asxk2mr4csj736tai7 https://uihnu0asxk2mr4csj736tai7.ewr.prisma.build
Without --environment it lists production. It finds the app by the name of the
entry's root module, so run it where you run prisma deploy, or pass
--name and --entry as you would to prisma deploy.
The root's platform ID is the Project's. A module has no platform ID, and nor does a resource with no row of its own on the platform, such as S3 credentials. The list is the topology the last deploy recorded: if that deploy stopped before a node's resource was created, the node is listed with no platform ID.
It fails with DEPLOY.TARGET_NOT_FOUND when the environment has nothing
deployed, and with DEPLOY.ENVIRONMENT_INVALID when the environment name is
not a valid git ref name. Piped, it writes one line per node: address, kind, platform ID and URL,
with an empty field for a missing value. With --json the result is an
array of { address, kind, platformId, url }, with null for a missing
value. prisma deploy list needs a prisma CLI release that includes it;
8.0.0-rc.26 does not.
Using an address with platform commands
A platform command whose subject is a project, service, database or bucket
takes @<environment>:<address> in place of the platform ID. Without an
environment, the address means production:
prisma service logs @pr-42:storefront-auth.auth.service
prisma postgres delete @storefront-auth.auth.database --confirm @storefront-auth.auth.database
The command finds the row whose logicalId is the address, then acts exactly
as it does when given the ID. Deleting a service, database or bucket this way
leaves the deploy state alone, so the next deploy recreates it. Deleting the
Project removes the deploy state with it, as described below. This needs a prisma CLI release
newer than 8.0.0-rc.28.
Removing an app or an environment
To remove an app with every environment, delete its Project. Its id is in the
id column of prisma project list:
prisma project list
prisma project delete proj_123 --confirm proj_123
prisma project list # the app is gone
This works while the app's services are running, and removes every environment, its resources and its deploy state.
To remove one environment and keep the rest, call the destroy operation from
@prisma/composer/control in a script, run from the directory you deploy
from. It refuses to guess: environment is required, even for production,
which is environment: 'production'. A call without it fails with
DEPLOY.ENVIRONMENT_REQUIRED.
// destroy-staging.ts
import { fileURLToPath } from 'node:url';
import { destroy } from '@prisma/composer/control';
import prismaConfig from './prisma.config.ts';
const result = await destroy({
environment: 'staging', // or 'production'
config: {
value: prismaConfig.composer,
file: fileURLToPath(new URL('./prisma.config.ts', import.meta.url)),
},
});
if (!result.ok) {
console.error(result.failure.message);
process.exitCode = 1;
}
Run it with the two variables under Credentials set, for
example bun destroy-staging.ts, or node destroy-staging.ts on a supported Node.js release (22.18 or newer on the 22 line, 24.11 or newer on the 24 line, or 26 or newer). A prisma auth login session is not used.
The three teardown shapes differ in what happens to state. Destroying any environment other than production removes its resources, then deletes its Branch — and the Branch takes the environment's deploy state with it. Destroying production removes the resources and empties production's deploy state as it goes, but the production Branch survives, so an emptied state scope remains until the Project itself is removed. Deleting the Project (below, or from the Console) removes every Branch and all state in one stroke. Destroy never creates: tearing down an environment that was never deployed fails with "nothing deployed" rather than provisioning one first.
Destroying production also removes the app's Project, so hand-run stacks don't pile up as empty Projects in your workspace. If the Project still holds another environment's resources, it's left in place. Removing the Project deletes every variable on the platform set on it, platform variables included, so set them again after the next deploy creates the Project.
CI
Nothing is CI-specific — set PRISMA_SERVICE_TOKEN and PRISMA_WORKSPACE_ID
as CI secrets, build, and run the same commands. The per-PR environment
pattern: on push, run prisma deploy --environment "pr-$PR_NUMBER"; on
close, run a script like the one under Removing an app or an environment
that passes that name, environment: 'pr-42' for PR 42.
One extra: if your app declares platform variables (see Building an app § Platform variables), they live on the platform, and CI does not supply them. Set each one once with --role preview, and every new pr-42 environment reads it (Platform variables). A variable a service needs that has no value fails the deploy, naming it. A root input field is different: the deploy reads it from the app configuration on every deploy, so CI exports it, or commits it in .env.<environment> and lists dotenv(), every time.
An ORM database migrates to its targetRef on every deploy (Building an app § postgres()). A targetRef computed as the environment's name needs a ref file for every environment it deploys, so per-PR environments need one rule for all of them, such as name.startsWith('pr-') ? 'preview' : name with a committed migrations/app/refs/preview.json, or '@contract' to migrate each preview to the contract the pull request emits. A deploy to an environment with no ref file fails with the ORM's MIGRATION.UNKNOWN_REF. So before the first deploy to a new environment name, commit its ref. From the directory of the prisma.config.ts that names the migrations, run prisma migration ref set <environment> <migration directory>, naming the newest migration the environment should reach, or prisma migration ref set <environment> production to point it at the same contract as production. Either way the new ref declares no policies. If you copy another environment's file instead, such as migrations/app/refs/production.json, you also copy its policies; check that they suit the new environment (When a deploy refuses a ref's policies).
A root's input can come from a committed .env.<environment> file per environment (Values from outside the code). Keep secrets out of committed files: put them in CI's secret store and keep environmentVariables() in secrets.
When a deploy refuses a ref's policies
A ref can declare policies for the database it targets: which ways of changing it are allowed, and what data loss or access widening a migration may cause. When the ref's policies differ from the ones the database has, every deploy of that environment fails with the ORM's MIGRATION.POLICY_MISMATCH and changes nothing, schema migrations included. A new database has the ORM's default policies, so a ref that declares others fails the database's first deploy the same way.
A deploy never changes a database's policies, and Composer has no setting that lets it. Whether the database takes the ref's policies is a decision for whoever administers the database. If they decide it should, they apply them by hand, once, from the app's directory:
prisma db migrate --to <ref> --permit-policy-change --db <url>
The next deploy then proceeds. If the ref is wrong instead, change the ref to match the database and commit it. A ref's policies are the policies field of its file, migrations/app/refs/<ref>.json; prisma migration ref policy show <ref> prints them, and prisma migration ref policy set <ref> changes them, for example prisma migration ref policy set production --change migrate.
The prisma db migrate --permit-policy-change command above does more than record the policies: it also applies every migration the ref's contract still needs. They run from the checkout the command runs in, and outside a deploy's ordering, in which a service starts only after its database's migration, so the code already deployed runs against the new schema until the next deploy. Run it from the merged commit. A team that wants its deploys to do all the schema work ships a change to a ref's policies in its own pull request, apart from a change to the contract.
The database's URL is not printed by a deploy. Copy the connection string from the Prisma Console: the app's Project for production, and the Branch named after the environment for any other environment. Or create a connection of its own from the app's directory: prisma postgres connection create @<environment>:<address> --name <name> --json, with <address> the database's address, such as @preview:shop.database, or @shop.database for production. Its output holds the new connection string, a secret shown exactly once, so keep it out of logs and shared terminals. For a local database, run prisma dev url <address> while prisma dev runs, with <address> the database's address, such as shop.database; it prints the connection string.
When a deploy stops on a missing connection value
A dependency's connection declares the values it needs, by name. The node on the other end of the wire has to supply them. When one doesn't, the deploy stops and names the edge rather than standing the app up:
Connection input "shop.auth.db" declares param "url", but its producer "shop.db" did not
supply it — the producer's outputs carry [host]. Add "url" to the outputs the
producer returns from its lowering, or declare the param optional on the
connection.
Two fixes, and which is right depends on whether the value is genuinely required:
- The producer should be supplying it — add the name to what the producer returns. This is the common case: the two sides drifted, usually a rename on one end only.
- Absent is legitimate — declare the param
optionalon the connection. The consumer then reads it asundefined, which is what it was already receiving.
Why an app you didn't touch can start failing this. It used to deploy. The
missing value reached the consumer as undefined, was written into its
environment, and broke at that service's boot — so the crash surfaced in the
service that read the value, not the one that failed to supply it, and the
stack trace pointed at the wrong end of the wire. The deploy now refuses up
front. Nothing about your app got worse; the same mistake now reports itself
where it was made, before anything is provisioned.
You'll only meet this if you wrote the connection or the extension on one side of the wire — every block that ships with the framework supplies what it declares.
When prisma.config.ts fails on an effect version conflict
alchemy, the deploy engine Composer drives, needs the exact effect version
@prisma/composer pins. The extensions in your composer section import
alchemy, so when your installed tree gives alchemy a different effect,
evaluating prisma.config.ts fails before any command runs:
CLI.CONFIG_UNREADABLE /path/to/prisma.config.ts could not be evaluated:
Schema.TaggedError is not a function
The message after the colon is the module error from inside alchemy, and it
varies with the versions involved. This happens when your app, or another
dependency of it, pins a different effect than @prisma/composer does and
your package manager hoists that copy where alchemy resolves it. npm allows
this with only a warning. A plain Composer app never hits it:
@prisma/composer and @prisma/composer-prisma-cloud pin every
effect-family package alchemy would otherwise float, so a fresh install
resolves a single effect.
The fix is to use the same effect as Composer. Match your own effect
dependency to @prisma/composer's exact pin (see its dependencies.effect),
or, when a dependency you cannot change pins another version, force
Composer's. <pin> below stands for that exact version (4.1.0 at the time of
writing). With npm, in your app's package.json:
"overrides": {
"effect": "<pin>"
}
With pnpm 11 and later, in pnpm-workspace.yaml (pnpm 11 ignores the
pnpm field of package.json):
overrides:
effect: <pin>
With pnpm 10 and earlier, nest the npm block under
"pnpm": { "overrides": ... } in package.json. With Yarn, the
package.json block is resolutions.
Reinstall afterwards — the setting only takes effect when the tree is rebuilt.
Production behavior
What deployed apps actually run into, and what to do about it:
-
Compute scales to zero, and idle database connections get closed. A long-lived client that treats a dropped connection as fatal will crash-loop through 502s. Keep the pool small and reconnect-friendly, and don't let an async error kill the process:
const sql = new SQL({ url: db.url, max: 1, idleTimeout: 10 }); process.on('uncaughtException', (err) => console.error('uncaughtException', err)); process.on('unhandledRejection', (err) => console.error('unhandledRejection', err)); -
Bind
0.0.0.0, not loopback. Compute routes external HTTP to the VM; alocalhostlistener is unreachable from outside. -
A deployed
/rpc/<method>returns401to you. RPC calls are authenticated for you, and yourcurlisn't one of the services the app connected to it — so it's turned away, and a provider with no consumers turns away everyone. Reach it through a consumer instead. -
The
COMPOSER_*variables in your project belong to the deploy. Ports, connection settings, generated values and service keys all land there, and every deploy rewrites them — editing one by hand doesn't survive. A service's input document is not among them: it travels in the service's artifact. -
Calls into a sleeping service can get
ECONNRESETwhile it cold-starts. Retry them. -
The
cronscheduler stays awake on purpose. It holds Compute's keep-awake guard for its whole lifetime, so it never scales to zero: one warm instance per app is the cost of the clock. Every other service, the runner included, sleeps as usual. -
Streaming responses don't stream. The platform's HTTP front door (the ingress) buffers a response until it completes, so an open SSE tail delivers nothing and times out at 60s. Don't build on streamed HTTP responses.
-
A new named hostname adds a DNS wait to the deploy. Before it attaches the hostname, the deploy asks the hostname's authoritative nameservers for its CNAME record, every 3 seconds for up to a minute, and waits 10 more seconds once they all answer. The machine that runs the deploy needs DNS access; if the lookups fail, the deploy goes ahead and the platform reports any missing record.
-
Next.js: pages that call
service.load()needexport const dynamic = 'force-dynamic'. The runtime environment doesn't exist at build time, and Next won't re-read it for prerendered routes.
When something misbehaves in ways these don't explain, check
gotchas.md at the repo root — the catalogue of platform
footguns with diagnoses, kept current as we hit them.
Upgrading to input documents in the artifact
Earlier versions wrote each service's input document as an environment
variable, COMPOSER_<ADDRESS>_INPUT. This version writes it into the service's
artifact. The first deploy with this version gives every service a new
deployment that reads its input from its artifact, then deletes the
COMPOSER_<ADDRESS>_INPUT variables. Nothing else changes, and there is
nothing to do yourself.
Don't put a deployment made before the upgrade back into service afterwards, for example by promoting it in the Console: its artifact has no input document, and the variable it read is gone.
Upgrading from stages to environments
A place the app runs used to be called a stage. It is now an environment, and
production has a name, production:
prisma deploy --stage <name>is nowprisma deploy --environment <name>.--stagefails withCLI.COMMAND_MOVED, naming the new flag.destroy({ target: ... })is nowdestroy({ environment }). Production isenvironment: 'production'.- The
--reportfile'sstagefield is nowenvironment, and itsversionis2. - The Prisma Cloud extension (
@prisma/composer-prisma-cloud) must be the same Composer version as the Composer that runs the deploy (theprismaCLI's, or your own@prisma/composerin a script). An older extension would read every environment as production, so a deploy or destroy with one fails withDEPS.EXTENSION_INCOMPATIBLEbefore anything is deployed or destroyed.prisma devrefuses it the same way, because it would run every local environment as one copy.
Upgrading to addresses that start with the app name
Earlier versions left the app name out of every address below the root
(auth.database instead of storefront-auth.auth.database), and named the
deploy engine's resources auth.database-db, auth.database-conn and so on.
The first deploy with this version moves every resource of an existing
environment to its new name in place. Databases keep their rows, buckets keep
their objects, and generated secrets and service keys keep their values. The
platform resources' logicalIds change to the full address in the same deploy.
Environment variable keys gain the app name (COMPOSER_STOREFRONT_AUTH_…): each
variable is replaced by one with the same value under the new key, and services
get a new deployment.
Every name Composer gives a platform resource becomes the full address too:
apps, buckets and Composer's database connections and bucket access keys are
named storefront-auth.auth.database and so on. Apps and buckets are renamed in
place, and custom domains stay. Each database connection and bucket access key
Composer made is replaced by a new one with new credentials, which your services
receive in the same deploy. The database and the bucket's objects are kept, and
connections, keys and environment variables you made yourself are not touched.
Anything outside the app that copied the old connection string or access key
needs the new one.
Two things to do yourself:
serviceOrigin()takes the full address. ChangeserviceOrigin('api')toserviceOrigin('<app>.api'). An address that names no service fails the deploy, naming the address, while it plans. By then the Project and the environment's Branch exist and the Branch's topology is the new one, but no resource has been created, changed or deleted. An app that usesserviceOrigin()can't be deployed under a different name with--name, because its addresses start with the app's own name.- Don't deploy an environment with an older version afterwards. It would look for the old names and recreate every resource, losing their data.
An app with a module or a service directly below the root named like the app
(shop.shop.x beside shop.x, in any letter case), or with modules that spell
an app name containing - or _ (my-shop.my.shop.x beside my-shop.x), can
hit one more step. There, one node's new variable key is the key an earlier
version wrote for another node. The deploy stops before any resource is created, changed or deleted, and
names the variable and both nodes. The Branch's topology in the Console already
shows the new addresses by then. It lists every such variable at once. Delete each,
then deploy again:
prisma project env delete 'COMPOSER_SHOP_X_ORIGIN' --project '<project-id>' --role production
prisma project env delete 'COMPOSER_SHOP_X_ORIGIN' --project '<project-id>' --branch '<branch>'
The first form is for production, the second for any other environment; the Console's Environment variables page works too. Nothing is lost: the deploy writes every value under its new key, and running services keep their own copy until then. Don't rename either node to get around it: a new address is a new entity, and its old rows, and a database's or bucket's data, are deleted.
prisma dev keeps its local services, databases and buckets: on its first run
it rewrites the directory's record to the new addresses. prisma dev url takes
the full address. prisma emulator list still shows an instance created before
the upgrade with its old address label (api instead of shop.api), because
the emulators keep the labels they were created with; prisma dev --fresh
recreates the instances with full addresses, and deletes their local data.
Upgrading from an older state store
Older framework versions stored deploy state differently: first in a workspace-level prisma-composer-state project, later in a small prisma-composer-state database on each environment's Branch. The current version stores state behind the platform's API and never reads either legacy store — there is no automated migration. The cutover is the same for both generations: destroy, upgrade, redeploy.
Deploying over a live legacy environment is refused up front. The deploy finds no API-hosted state but sees resources (apps, databases, or buckets) already on the Branch, and stops with an error saying the environment has no deploy state but its Branch already holds resources — instead of blindly recreating every resource and failing halfway. Cut over per app:
- On the old framework version, destroy every environment: each named one, then production. (Equivalent: delete the environment's Branch — or the whole Project, for production — in the Console or via the Management API.)
- Upgrade the framework packages.
- Deploy again — each environment starts fresh, hosted behind the platform state API.
Recreated apps get new generated URLs; anything pointing at the old ones needs updating.
Legacy leftovers are inert and safe to remove whenever convenient — nothing reads them after the upgrade, and each costs only a database quota slot:
- Branch-hosted generation: destroying on the old version already removed the environment's
prisma-composer-statedatabase. If you skipped that and deleted Branches by hand instead, each Branch took its database with it — but production's, on the default Branch, survives: delete it in the Console. - Workspace-hosted generation: delete the workspace-level
prisma-composer-stateproject from the Console.
Upgrading to the upstream Prisma resources
Framework versions that manage databases, apps, deployments, and environment variables through upstream alchemy's Prisma provider adopt each environment's existing resources in place — deploy state already in the platform state API is migrated automatically on read (rows written under retired type-ids), and existing databases and connections are adopted, never replaced. The first redeploy can still converge database properties in place — Branch attachment and display name — as the one-time effects below describe. Environments still on the older SQL state store are not migrated — destroy and redeploy them, as the section above describes.
A service's deployment is replaced exactly when its artifact or environment changed, and reused otherwise. The platform freezes a deployment's environment when the deployment is created, so a changed value only takes effect through a new one — the framework declares each service's environment values as the deployment's replacement triggers (alchemy's Prisma.Deployment.triggers), so a changed variable, a value re-issued in place (a connection rotated in place, a re-minted service key), or an out-of-band rotation of a platform variable a service's input document names all ship a new deployment, and an unchanged service redeploys nothing. No plaintext lands in deploy state — alchemy persists only a salted fingerprint of the trigger values. A replacement uploads the artifact, starts it, moves the stable endpoint over, and removes the old deployment; your service's URL does not change.
The framework never writes, modifies or deletes DATABASE_URL or DATABASE_URL_POOLED. Prisma Cloud writes them only when a project is created with a database, or when a database is created as the project's default. The framework creates your project without one, so on a project it created neither variable exists unless you set it. On a project created outside the framework with a default database, both hold live values, and every service on production receives them, as on any Prisma Cloud project. Nothing you declare can carry those names (variable() and variable.secret() reject them), and every database URL your services use comes from the connection they declare.
Earlier framework versions wrote the placeholder "-" under both names, in the production and preview classes. Those rows stay on existing projects. Nothing in the framework reads them; delete them in the Console if you like, or replace them with your own value for a tool outside the framework that insists on DATABASE_URL.
On the first deploy after upgrading from a version that tracked the two variables in deploy state, the framework stops tracking them. The deploy log reports them as retained: the entry is dropped from state and no call is made to Prisma Cloud.
Environments other than production see two one-time effects on their first deploy after the upgrade, because a branch-attached database can no longer carry an explicit display name at create:
- Each existing database in such an environment is renamed to a generated physical name (
<app>-<resource>-db-<branch-id>-<suffix>). The database itself, its data, and its ID are untouched — only the display name in the Console changes. - The database's default connection credentials are rotated during that same reconcile. The framework's own named connection — the one your services actually use — is NOT rotated and keeps working. Only credentials minted outside the framework from the database's default connection (for example, copied out of the Console) stop working and must be re-issued.
Production databases created by earlier versions attach to the default Branch on their next deploy. Earlier versions created production's databases with no Branch — they showed as Unassigned in the Console, and every redeploy re-enforced that — while production's compute services sat on the default Branch. Every database now attaches to its environment's Branch: production's to the project's default Branch, any other environment's to that environment's Branch, matching the compute services and the Branch-scoped model above. The first production deploy after the upgrade converges each existing database in place: it is attached to the default Branch and renamed to the same generated physical-name shape other environments use (an explicit display name cannot be combined with branch attachment). The database, its data, and its ID are untouched — this is an update of the existing database, never a replacement.
That same reconcile can also rotate the database's default connection credentials, exactly as the bullet above describes: rotation happens when the deploy state carries no stored connection secrets for the database — always the case for state migrated from the legacy store. The framework's own named connection — the one your services actually use — is NOT rotated and keeps working. Only credentials minted outside the framework from the database's default connection (Console-copied URLs, BI tools, backup jobs) stop working and must be re-issued.
Local dev state written with retired resource types is not converted: if prisma dev fails at plan time with No provider is registered for resource type 'PrismaComposer.…', run it once with --fresh to clear the stale local state.
Upgrading to a required targetRef
postgres({ name, contract, config }) now needs targetRef, and every deploy runs the ORM's migrate to it. Before, a deploy migrated to the contract your commit emitted unless targetRef was set, skipped the migrate when it judged the database already there, and refused any ref that declared policies. To upgrade an app:
- Add
targetRefto everypostgres({ ... })resource. For an app that deploys to environments,targetRef: resolve([environment.name], ([name]) => (name === 'dev' ? '@contract' : name))migrates each environment to the ref named after it andprisma devto the contract you emit. A Module whose migrations ship in its own package uses'@contract'. - For each environment you deploy, commit a ref that points at the newest migration:
prisma migration ref set <environment> <newest migration directory>, for exampleprisma migration ref set production 20260711T1921_init. Run it from the directory of theprisma.config.tsthat names the migrations, or pass--config. - Remove any placeholder
db: { connection: … }from thoseprisma.config.tsfiles. The deploy passes the ORM the database it provisioned, so the config names none.
A ref that already declares policies now takes effect: if they differ from the database's, the first deploy after the upgrade fails until whoever administers the database applies them (When a deploy refuses a ref's policies).
A database whose schema an older framework version synthesized at first deploy, with no migration authored, is at a contract no migration in your graph reaches. Its deploy fails with the ORM's MIGRATION.SIGNATURE_NOT_IN_GRAPH, whose why names the database's contract and whose next actions are the ways back onto the graph. Follow them; none of them resets the database.
Upgrading to Prisma ORM's new contract hashes
Composer 0.41.0 moved to Prisma ORM 8.0.0-rc.26, which computes every contract hash in a new way. This version of Composer uses Prisma ORM 8.0.0-rc.28. Prisma ORM 8.0.0-rc.27 fixed how rc.26 signed a database that a deploy creates, and 8.0.0-rc.28 fixes the ORM's upgrade instructions; upgrade from rc.25 to rc.28 in one go with the steps below. If you already upgraded with Composer 0.41.0 or 0.41.1, follow Upgrading from Composer 0.41.0 or Upgrading from Composer 0.41.1 instead. Your contract, its migrations, their snapshots, your refs and each database's contract signature all move to the new hashes together, once. Until a database is signed with the new hashes, its deploy fails at the migration step with the ORM's MIGRATION.SIGNATURE_NOT_IN_GRAPH. Whatever that error advises (the ORM's signing step, prisma db update, or writing new migrations), sign the database as step 7 says. Step 7 is Composer's form of the ORM's signing step: you sign by hand after the deploy stops, not in the deploy. Do not run prisma db update: it changes the schema outside migrations. The service already deployed keeps running meanwhile.
- Before you upgrade, deploy with the versions you are on, so every database (each environment, and your
prisma devdatabase) has every migration you have committed. A deploy migrates only to the environment'stargetRef, so first move every environment's ref to your newest migration. The upgrade signs each database at your newest contract, which is safe only for a database that is already there. For a database you keep behind on purpose, follow the ORM's section "A database that is still behind" in place of step 7. - Make the upgrade a release of its own, with no new migration of yours in it, and commit your work first, so the changes below can be reviewed. There is no going back once a database has seen the new version: the first deploy or
prisma devon it, even one that fails, moves the ORM's own tables from the schemaprisma_contracttoprisma. An earlier Composer that deploys to that database afterwards finds no record of its migrations and applies every one of them again, data migrations included. From the first deploy on, every deploy,prisma devand script that changes that database must run the new version. - Upgrade
@prisma/composerand@prisma/composer-prisma-cloudto this version, and@prisma/composer-clitoo if your app lists it (prismabrings its own). Upgrade@prisma/orm-postgresto 8.0.0-rc.28, andprismato the release whose dependencies are@prisma/orm-toolchain8.0.0-rc.28 and@prisma/composer-cliat this version;npm view prisma@<version> dependenciesshows both. Add@prisma/orm-framework,@prisma/orm-family-sql,@prisma/orm-target-postgresand@prisma/orm-toolchainat 8.0.0-rc.28 to the dependencies of everypackage.jsonthat lists@prisma/orm-postgres(in a monorepo, each package with a database, not only the root), andtemporal-polyfillat^1.0.8: the ORM's packages now name each other as peer dependencies, so the app lists each one (Building an app). This version of Composer also requirestargetRefon everypostgres({ ... })resource. If your app does not set it yet, the type check fails with TS2769, "No overload matches this call", onpostgres({ name, contract, config }), without namingtargetRef; follow Upgrading to a requiredtargetRefas part of this upgrade, after step 5 and before step 6, so that the refs it commits use the new hashes. - Follow the ORM's upgrade instructions from 8.0.0-rc.25 to 8.0.0-rc.28, with 8.0.0-rc.28 installed. The copy of the instructions installed with rc.25 reads older guides, so start from rc.28's upgrade reference and follow it from its first step, or ask your coding agent to do so. Tell it the project upgrades from 8.0.0-rc.25 to 8.0.0-rc.28: step 3 already installed rc.28, so the lockfile no longer shows where you started, and the reference's own bump and install steps are already done. Its first step downloads the newest release's guides and scripts and runs them from there; do not run
prisma skills syncuntil the upgrade is done. The rc.25-to-rc.26 instructions'contract-hash-inputsscript rewrites the hashes in your committed files, including the copy of the auth module's migrations inmigrations/auth/. It refuses a contract undermigrations/that still uses the names from before 8.0.0-rc.13 (tableandcolumn) for a generated column value, and prints the command of the rc.13 script that renames them; run that command, then the hash script again. Composer 0.40.0'sorm-demoexample had such a snapshot. Their capabilities step addsrequiredCapabilitiesto your contract entry inprisma.config.ts; Prisma Postgres runs PostgreSQL 17, so use[...postgres17, ...postgresDriver]. - Run
prisma contract emitand commit the result with the script's changes. It also writes your contract's required capabilities into its snapshot undermigrations/snapshots/, which a deploy to a ref signs a new database with. If it warns withMIGRATION.CONTRACT_SNAPSHOT_PROFILE_NOT_UPDATED, it left that snapshot as it was; do what the warning says before you merge. Otherwise each deploy whosetargetRefnames that contract either stops at the migration step or signs a new database so thatprisma db verifyfails; the warning says which. - Before you merge, run the queries in the section "Check each database before the deploy" of the ORM's instructions against each database, and wait until every deploy already started has finished. Then merge the upgrade and let it deploy. Merge nothing else until that deploy has run, and never re-run a deploy of an earlier commit. Each environment's deploy stops at the migration step, and the service already deployed keeps running. That step is the first command of the new version to change the database, so it moves the ORM's own tables from the schema
prisma_contracttoprisma(step 2) and then stops withMIGRATION.SIGNATURE_NOT_IN_GRAPH. From that moment, a deploy of an earlier commit would run the old version against the database and apply every migration again (step 2). That is why you sign only now: signing first would move the tables while a pull request merged before the upgrade could still deploy the old version. Once the upgrade is merged, every later deploy runs the new version. - Sign every database the app already has. The database does not change; only its signature moves to the new hashes. Moving the ORM's tables stops without changing anything when one of the checks in the section "Check each database before the deploy" of the ORM's instructions fails, for example when the role that runs the command does not own
prisma_contractand its tables, or lacksCREATEon the database. If the deploy in step 6 stopped for that reason, the tables have not moved, and the signing command moves them, with the same checks. On a Prisma Postgres database Composer created, the connection string from the Console belongs to the role that owns them. Runprisma db sign --no-advance-ref --db <url>from the directory of eachprisma.config.ts, once per environment, and once for the local dev database. It signs your app's space at your newest contract and each extension's space, such as the auth module's, at that extension's newest contract, and prints a line per space such asapp: signed 0d5d438… (was 175be57…). A database whose change policy permits only migrations, usually production, refuses with "This database's change policy permits only migrations"; for it, add--force, which overrides only that refusal:db signstill checks that the database matches each contract, changes no table, and leaves the policies as they were.- Deployed environments. A deploy never prints a connection string. Copy each database's connection string from the Prisma Console: the app's Project for production, and the Branch named after the environment for any other environment.
- An environment the merge did not deploy, such as an open pull request's preview environment. Its branch still runs the old version, so signing it now would move its tables and its next deploy would apply every migration again. Merge the upgrade into that branch and let it deploy first, as in step 6, then sign from that branch's checkout; or remove the environment.
- The local dev database. It must be running:
prisma db sign --no-advance-ref --db "$(prisma dev url <database address>)". Sign before you runprisma devon the new version, because aprisma devthat fails stops the app andprisma dev urlreports only a running database. Aprisma dev --detachstarted before the upgrade keeps the database running. If the database is already stopped, start over withprisma dev --fresh, which deletes the local data.
- Run each environment's deploy again, and run
prisma devas usual. A database created from now on needs no signing when its ref names the contract step 5 emitted or a later one, because its deploy signs it from that contract's snapshot, or when itstargetRefis'@contract', because it is signed from the emitted contract. A ref that names an older contract keeps that contract's old capabilities in its snapshot, so a database created for it failsprisma db verifywith "The database is signed for other capabilities" until the ref moves to the contract step 5 emitted or a later one and that deploy has run.
After the upgrade, prisma migration status no longer shows the migrations applied before it as applied, because the database's history keeps their old hashes. It still reports the database as up to date, and prisma db migrate does not run them again.
Upgrading from Composer 0.41.0
Composer 0.41.0 used Prisma ORM 8.0.0-rc.26, whose prisma contract emit left your contract's snapshot under migrations/snapshots/ with the capabilities it had before the upgrade. A database migrates to its targetRef on every deploy and every prisma dev. When the targetRef is a ref name, the ORM signs a database it creates with the capabilities in the snapshot of the contract that ref names. So prisma db verify fails against such a database created on 0.41.0, with CONTRACT.SIGNATURE_MISMATCH, "The database is signed for other capabilities". Its queries still run, and nothing appears in your service's logs, because Composer's clients do not check the signature unless your app turns the check on through clientWith: prisma db verify is the only way to find an affected database. A database whose targetRef is '@contract', such as a Module's own database or a local dev database under the pattern in Upgrading to a required targetRef, is signed from the emitted contract and is not affected. Neither are the databases you signed by hand during the upgrade.
- Upgrade
@prisma/composerand@prisma/composer-prisma-cloudto this version, and@prisma/composer-clitoo if your app lists it. Upgrade every@prisma/orm-*package to 8.0.0-rc.28, andprismato the release whose dependencies are@prisma/orm-toolchain8.0.0-rc.28 and@prisma/composer-cliat this version;npm view prisma@<version> dependenciesshows both. - Follow the ORM's upgrade instructions from 8.0.0-rc.26 to 8.0.0-rc.28, starting from rc.28's upgrade reference as step 4 above says, or ask your coding agent to do so, telling it the project upgrades from 8.0.0-rc.26 to 8.0.0-rc.28. The guide from rc.27 to rc.28 has no entries; the one from rc.26 to rc.27 does. Besides the snapshot, rc.27 has changes to the ORM's API that may affect your code. The rc.26-to-rc.27 guide's step for the snapshot is to run
prisma contract emitfrom the directory of eachprisma.config.ts, and commit the files it changed undermigrations/snapshots/if it reports a snapshot it updated. It updates only the snapshot of the contract you emit, which is the one a ref at your newest contract names. If it warns withMIGRATION.CONTRACT_SNAPSHOT_PROFILE_NOT_UPDATED, do as step 5 of the main upgrade says: the hash script shipped with Composer 0.41.0 could write new hashes over a snapshot with the names from before rc.13. - Merge and let it deploy.
- From the directory of each
prisma.config.ts, runprisma db verify --db <url>against each database created since you upgraded to 0.41.0 whosetargetRefis a ref name, such as a new environment's or a preview environment's. Copy each connection string as step 7 above says; a local dev database's isprisma dev url <database address>, which reports only a running database. Where it fails with "The database is signed for other capabilities", runprisma db sign --no-advance-ref --db <url>, with--forcewhere the change policy permits only migrations.db signsigns the contract of the checkout you run it from, after checking that the database matches it, so the database must be at that contract:- An environment the step 3 merge deployed, whose ref names your newest contract. Sign it after that deploy has finished.
- An environment the merge did not deploy, such as an open pull request's preview environment. Its branch may be at another contract than yours. Merge this upgrade into that branch and let it deploy, then sign it from that branch's checkout.
- An environment whose ref names an older contract than your newest. Do not sign it:
db signwould sign it at your newest contract, which its database is not at. The first deploy after its ref moves to a newer contract applies the migrations and writes the right signature. Until then, a new database created for that ref failsprisma db verifythe same way. Runprisma db verifyagain after that deploy.
Upgrading from Composer 0.41.1
Composer 0.41.1 used Prisma ORM 8.0.0-rc.27, and the ORM's guide from rc.27 to rc.28 has no entries. Upgrade the packages as step 1 above says, and run prisma contract emit from the directory of each prisma.config.ts. If it warns with MIGRATION.CONTRACT_SNAPSHOT_PROFILE_NOT_UPDATED, do as step 5 of the main upgrade says: the hash script shipped with Composer 0.41.1 could write new hashes over a snapshot with the names from before rc.13. Then run your checks and deploy as usual. Nothing needs signing.
Driving deploys from code
@prisma/composer/control exports typed deploy, destroy, dev, devUrl,
devStop and log operations that return structured results instead of
printing and exiting. prisma deploy, prisma dev, prisma dev url and
prisma dev stop are thin renderers over the deploy, dev, devUrl and
devStop operations, so the two surfaces can't drift. destroy and log have
no command; these operations are how you run them. They read their
credentials from the environment (see Credentials).
A script imports only @prisma/composer/control. The extensions' own
/control entries, such as @prisma/composer/node/control and
@prisma/composer-prisma-cloud/control, are different: only
prisma.config.ts imports them (ADR-0017), and the script reaches them
through that file's composer section.
import { fileURLToPath } from 'node:url';
import { deploy } from '@prisma/composer/control';
import prismaConfig from './prisma.config.ts';
const result = await deploy({
environment: 'pr-42',
config: {
value: prismaConfig.composer,
file: fileURLToPath(new URL('./prisma.config.ts', import.meta.url)),
},
});
if (result.ok) {
// result.value.summary — the deployed topology (app name + each node's
// address and entities) and the platform variables with no value
// (`findings`), when the deploy engine reported one.
} else {
console.error(result.failure.message); // same fix-naming text the CLI prints
}
What to know before embedding it:
- You pass the config. Each operation takes a
required
config: { value, file }(theComposerConfigSourcetype): thecomposersection of yourprisma.config.tsand the path of the file that declares it. A relativefileresolves againstcwd, not against your script, which is why the example builds an absolute one. The operations do not look for a config file themselves, but they refuse a config the CLI would refuse, before any work starts: avaluethat fails the section's checks (passing the whole export instead of itscomposerproperty is aCONFIG.FIELD_UNKNOWNthat says so), aprisma-composer.config.*besidefile(CONFIG.FILE_RETIRED), or afilethat does not exist (CONFIG.FILE_MISSING). The deploy importsfileagain while it runs and uses itscomposerexport, sovaluemust be that export.logreads onlyvalue. - Inputs mirror the flags, but typed. A bare
deploydeploysproduction, exactly like the CLI. The entry is the section'sentry; anentryinput replaces it, resolved againstcwd, as--entrydoes.destroyhas no default: itsenvironmentis required, so a script that forgets it fails withDEPLOY.ENVIRONMENT_REQUIREDinstead of tearing down production. - Failures are results, not throws. Every operation resolves to
{ ok: true, value }or{ ok: false, failure }.failureis a structured error with a dottedcodefrom a closed registry — for exampleCONFIG.FIELD_INVALID,ASSEMBLE.BUILD_FAILED,DEPLOY.ENGINE_FAILED, orDEPS.EXECUTOR_UNLOADABLEwhen the deploy engine cannot be imported — and the same fix-namingmessagethe CLI prints; branch oncode. When the deploy engine ran and failed (DEPLOY.ENGINE_FAILED), the message ends with the engine's own errors, whole, with every secret Composer knows redacted. An error that was structured, such as the ORM's, is shown in the layout the CLI prints errors in: its code and summary, itswhy, one→line per next action and its docs link, with the structured error it was caused by indented under it.failure.meta.reasonsholds each of those errors as data, with the same fields, its next actions as{ kind, label, command?, commands?, url?, reason? }objects, and itscause; the--reportfile carries them asfailure.reasons, andprisma dev'sconverge-failedevents asreasons. A deploy reporting to Prisma Cloud also records the message on the build, which holds at most 5000 characters: when it is longer, the middle of the longestwhyis cut out, so the next actions at the end survive. Adeploystopped by itssignalfails withDEPLOY.INTERRUPTED, after it has released the environment's lease. Adestroystopped by itssignalfails the same way. Importing the module executes nothing until you call an operation. - Composer replaces every secret it knows with
[redacted]in the deploy engine's output: the value under the name of each platform secret your app declares, in yourconfigandsecretslists, however short. Other values in those lists, such as the shell's, are printed as they are, apart from values that look like credentials, such as a long value under a name containingTOKENorKEY.deployanddestroyredact each engine event and log line beforeonEventreceives it. onEventreports each step. PassonEventtodeployto receive astep-startedand astep-finishedevent per step (prepare,assemble, oneassemble-serviceper service,connect,preflight,apply, oneapply-resourceper resource the engine touches, with itsresourceIdand the engine'sstatusword, which is for people to read,record), as they happen, and amessageevent for each line the engine logs. A finished step hasoutcome,durationMsand thedatadescribed in What a deploy prints. Right afterpreflight, apreflight-findingsevent lists the platform variables with no value that no service needs, when there are any. When a step fails, it and the steps around it finish asfailed;recordstill runs. AnonEventthat throws does not fail the deploy. A successful result'sdurationMsis the whole deploy's total.destroytakesonEventtoo and reports the same steps withoutpreflight, and oneno-local-deploy-stateevent aspreparestarts when the working directory has no.alchemydirectory.deployanddestroyrun the engine in your process.deployreturnssummaryas a value and reports the engine's progress throughonEvent; it prints nothing. While it plans and applies it sets each deploy reporter's variables inprocess.envand changes tocwdwhen your process is elsewhere, then restores both, so a process runs one deploy or destroy at a time (DEPLOY.CONVERGE_RUNNING), and from a worker threadcwdmust be the process's working directory (DEPLOY.WORKER_THREAD). Both use the lowering and the converge from the app's own install of@prisma/composer, found beside itsprisma.config.ts, which must speak the same converge contract as the Composer running the operation (DEPS.CONVERGE_CONTRACT_MISMATCHotherwise); the package versions may differ. Passsignalto interrupt either.devresolves to{ ok: true, value: session }or a failure — never an exit code. The session is{ endpoints, stop(), closed }, with progress (ready,converge-failed,config-changed,watch-error, …) delivered throughonEvent. The operation never installs signal handlers; wiring Ctrl-C tosession.stop()is yours.logresolves to{ ok: true, value: { appName, services, lines } }or a failure.linesis anAsyncIterableended by anAbortSignalyou own (stopping early —break,lines.return()— also ends it cleanly). Zero running services is a valid result (emptyservices, finished stream), not an error. A consumer that falls behind loses oldest lines past a bounded queue and is told via alines-droppedevent.
The full picture
docs/design/10-domains/deploy-cli.md
documents the deploy pipeline end to end — environments and containers, the destroy
contract, the error surface.