Postgres
A Prisma.Project owns everything; a Prisma.Postgres database
lives inside it. Declare both and alchemy converges them like any
other resource.
Project
Section titled “Project”import * as Prisma from "alchemy/Prisma";
const project = yield* Prisma.Project("app", { createDatabase: false, region: "us-east-1",});By default, creating a project also provisions a default Prisma
Postgres database in the chosen region. Pass
createDatabase: false (as above) when you’d rather declare
databases explicitly — the recommended shape, since standalone
databases have their own lifecycle and outputs.
Database
Section titled “Database”Prisma.Postgres and Prisma.Database are the same resource under
two names — use whichever reads better:
const postgres = yield* Prisma.Postgres("db", { project, region: "us-east-1",});Omit name and alchemy generates a stable physical name, so an
interrupted create recovers instead of duplicating the database.
Branches
Section titled “Branches”A Prisma.Branch groups databases under a git-style name, and a
database attaches to one by branchId (or branchGitName):
const branch = yield* Prisma.Branch("preview", { project });
const previewDb = yield* Prisma.Postgres("preview-db", { project, branchId: branch.branchId,});See Branches for preview-per-stage patterns and default-branch promotion.
Local dev
Section titled “Local dev”Under bun alchemy dev, the database resolves to a local
@prisma/dev Postgres instead of the cloud — same outputs, zero
provisioning. The dev prop tunes it:
const postgres = yield* Prisma.Postgres("db", { project, dev: { // run migrations once the local server is ready, with // DATABASE_URL pointing at it migrate: "bun run db:setup", },});persistenceMode: "stateless" gives you a fresh database on every
dev session; the default ("stateful") keeps data across restarts.
Where next
Section titled “Where next”- Connections — credentials, connection strings, and origins for Hyperdrive.
- Compute — deploy an app next to the database.
Reference: