Set up a brand-new Prisma ORM v7 project: initialize the CLI, configure prisma.config.ts and schema.prisma with a datasource, install a driver adapter, and generate a working Prisma Client.

domain: prisma.io · 8 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Create and enter a project directory, then init a TypeScript project: `mkdir my-app && cd my-app && npm init -y && npm install typescript tsx @types/node --save-dev && npx tsc --init`. Set `"type": "module"` in package.json and in tsconfig.json set `module: "ESNext"`, `moduleResolution: "bundler"`, `target: "ES2023"` (Prisma's generated client is ESM-first as of v7).
  2. Install Prisma CLI and client packages, plus the driver adapter for your database, e.g. for Postgres: `npm install prisma --save-dev && npm install @prisma/client @prisma/adapter-pg dotenv`. (SQLite: `@prisma/adapter-better-sqlite3`; other DBs have their own `@prisma/adapter-*` package.)
  3. Run `npx prisma init --datasource-provider postgresql` (or `sqlite`, `mysql`, `sqlserver`, `mongodb`, `cockroachdb`). This scaffolds `prisma/schema.prisma`, a `prisma.config.ts` file, a `.env` file with `DATABASE_URL=...`, and `.gitignore` entries.
  4. In `prisma.config.ts`, confirm the datasource URL is wired to the env var: `import { defineConfig, env } from "prisma/config"; export default defineConfig({ schema: "prisma/schema.prisma", migrations: { path: "prisma/migrations" }, datasource: { url: env("DATABASE_URL") } });`. Prisma v7 reads the connection URL from this config file, not from `schema.prisma`.
  5. Edit `prisma/schema.prisma` to add your models under the existing `generator client { provider = "prisma-client" output = "../generated/prisma" }` and `datasource db { provider = "postgresql" }` blocks.
  6. Create the database schema and generate the client: `npx prisma migrate dev --name init` (creates tables) then `npx prisma generate` (Prisma v7 no longer runs `generate` automatically after `migrate dev`).
  7. Instantiate Prisma Client with the driver adapter (required in v7): `import { PrismaClient } from "../generated/prisma/client"; import { PrismaPg } from "@prisma/adapter-pg"; const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL }); const prisma = new PrismaClient({ adapter });`
  8. Reference: https://www.prisma.io/docs/prisma-orm/quickstart/sqlite, https://www.prisma.io/docs/cli/init, https://www.prisma.io/docs/orm/reference/prisma-config-reference

Known gotchas

Related routes

Configure and run Prisma's integrated database seeding via prisma db seed, including wiring the seed command in prisma.config.ts and initializing Prisma Client with a driver adapter inside the seed script.
prisma.io · 6 steps · unrated
Introspect an existing database and generate/refresh a Prisma schema from it using prisma db pull, then produce a working Prisma Client from the introspected schema.
prisma.io · 7 steps · unrated
Create and apply a new development migration from Prisma schema changes using prisma migrate dev, safely, including handling shadow-database drift prompts.
prisma.io · 7 steps · unrated

Give your agent this knowledge — and 17,200+ more routes

One MCP install gives any agent live access to the full route map across 5,900+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans