All jobs

Upgrade a Project to Prisma 7

Yes. An agent moves your app from Prisma 6 to 7: prisma.config.ts, the prisma-client generator, the pg adapter and the changed CLI scripts, tested, in a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent starts from what version 6 looks like in the repository. In an app laid out like trpc/examples-next-prisma-starter, package.json has @prisma/client and prisma at ^6.7.0, a prisma.seed key of tsx prisma/seed.ts, and scripts that lean on the CLI: generate runs prisma generate, migrate runs prisma migrate deploy, migrate-dev runs prisma migrate dev, prebuild runs generate then migrate, postinstall runs pnpm generate, and dx:next chains migrate-dev, db-seed and next dev. prisma/schema.prisma has a postgres datasource with url = env("DATABASE_URL"), a prisma-client-js generator with no output, and one Post model with a UUID id. src/server/prisma.ts creates new PrismaClient({ log: [...] }) once and caches it on globalThis; src/server/routers/post.ts imports type { Prisma } from '@prisma/client'; prisma/seed.ts imports PrismaClient from the same package. .github/workflows/main.yml runs on Node 22 with a Postgres service, pnpm prebuild, pnpm build, Playwright and Vitest; vitest.config.mts loads dotenv/config, and dotenv is already a dev dependency.

Prisma 7 changes four things this project depends on. Configuration moves out of the schema into a prisma.config.ts at the project root, built with defineConfig and env from prisma/config: schema, migrations.path, migrations.seed and datasource.url live there, and url in the schema's datasource block is deprecated. The CLI no longer loads .env on its own, so the config file imports dotenv/config first. The generator becomes provider = "prisma-client" with a required output, and the client is no longer written into node_modules, so every import of @prisma/client changes to the generated path. And every connection goes through a driver adapter: for Postgres that is @prisma/adapter-pg, with new PrismaPg({ connectionString }) passed as adapter to new PrismaClient({ adapter }); the datasourceUrl and datasources constructor options are gone. The minimum runtime is Node 20.19 and TypeScript 5.4, which this repository's CI and typescript ^5.9.2 already satisfy.

The agent makes those changes in order. It bumps both packages to 7, adds @prisma/adapter-pg, writes prisma.config.ts with the seed command copied from the package.json key it then removes, sets the generator to prisma-client with output = "../src/generated/prisma" and adds that directory to .gitignore because postinstall regenerates it. src/server/prisma.ts becomes the one place the adapter is built, from env.DATABASE_URL, keeping the globalThis cache and the log option; post.ts and seed.ts switch their imports to ~/generated/prisma/client. The CLI scripts are reviewed line by line: migrate dev and db push no longer run generate, and migrate dev and migrate reset no longer seed, so dx:next keeps its explicit db-seed step and prebuild keeps generate before migrate; the --skip-generate and --skip-seed flags, had they been present, would be removed. $use middleware does not exist in this project, so there is nothing to port to $extends.

Then it proves the result in the sandbox against a real Postgres, the way main.yml does: pnpm install, pnpm prebuild to generate and apply the four existing migrations, pnpm db-seed, pnpm build, pnpm test-unit for the caller-based test in post.test.ts, pnpm tsc and the Playwright smoke test that adds a post through the page. The pull request also notes the behaviour changes a reader cannot see in a diff: pool defaults now come from the pg driver rather than the engine, and invalid TLS certificates are no longer ignored, so a database with a self-signed certificate needs ssl options on the adapter.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Upgrade this project from Prisma 6 to Prisma 7. Read package.json, prisma/schema.prisma, the migrations under prisma/migrations, prisma/seed.ts, src/server/prisma.ts, src/server/env.ts, every file that imports from @prisma/client, .env, vitest.config.mts, playwright.config.ts and .github/workflows/main.yml first, and read Prisma's upgrade guide for version 7. Bump @prisma/client and prisma to 7 and add @prisma/adapter-pg. Create prisma.config.ts at the root with defineConfig from prisma/config, importing dotenv/config first, carrying the schema path, the migrations path, the seed command from the package.json prisma key (which you remove) and the datasource url from DATABASE_URL; remove url from the schema datasource. Change the generator to prisma-client with an output under src/generated, add it to .gitignore, and update every import to the generated client. Construct PrismaClient with a PrismaPg adapter in src/server/prisma.ts, keeping the globalThis cache and the log option. Review every CLI script for the generate and seed steps migrate dev no longer runs. Start Postgres in the sandbox, run pnpm install, pnpm prebuild, pnpm db-seed, pnpm build, pnpm test-unit, pnpm tsc and pnpm test-e2e, and open a pull request that quotes their output and lists each breaking change from the guide with what you did about it, including the pool-default and TLS changes.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

The pull request changes package.json (versions, the new adapter, the removed prisma.seed key), the lockfile, prisma/schema.prisma, a new prisma.config.ts, .gitignore, src/server/prisma.ts, src/server/routers/post.ts, prisma/seed.ts, and any other file that imported @prisma/client. Its description is a table of the version 7 breaking changes from the upgrade guide, each with the file that addresses it or the words not applicable, followed by the output of the build, the unit test, the type check and the end-to-end test from the sandbox.

A reviewer checks that prisma.config.ts reads the same DATABASE_URL the application reads, that the generated directory is ignored and regenerated by postinstall, that no @prisma/client import remains, and that the migrations directory is untouched: an upgrade must not add a migration. They also read the note on pool defaults and TLS and decide whether production needs adapter options before this merges.

After merge, pnpm dx still starts a developer with migrations, seed and the dev server, CI runs the same workflow with no changes to main.yml, and queries run through the version 7 client without the Rust engine binary.

Run it on every Prisma release

The GitHub release feed for prisma/prisma is the event. GitHub's own webhooks cannot send a custom Authorization header, so a small handler on the reader's server receives the release event, checks the tag is a new major, and calls the automation's webhook trigger URL with Authorization: Bearer <the trigger's secret> and an Idempotency-Key of the release id, so GitHub's redelivery starts nothing new. That automation's run is read-only: it reads the release notes and the repository and posts its findings on an issue as a plan.

The upgrade itself is a run the handler starts with this body through POST /o/{org}/sessions, with the repository in resources and a request_id that is a UUID v5 of the release tag, so a retried call returns the run it already started. One run per repository that pins prisma, each reading its own schema and scripts.

The use case this job follows, with its automation and trigger: Upgrade dependencies weekly.

Why run it on Rush?

A major upgrade like this one touches configuration, generated code, imports, scripts and runtime behaviour at once, and the only way to know it holds is to run migrations, seed, build and tests against a real database. The agent does that in its own sandbox with a Postgres it starts itself, and the pull request carries the output of every step.

A team with several services on Prisma runs the upgrade on all of them at once, each in its own sandbox, each producing its own table of breaking changes against its own code. A service that uses $use middleware gets a port to $extends; one that does not gets the words not applicable, and the reviewer can tell the difference.

Frequently asked questions

Why does the CLI stop finding DATABASE_URL?

Prisma 7's CLI no longer loads .env automatically. The agent imports dotenv/config at the top of prisma.config.ts, using the dotenv package the project already has as a dev dependency, so prisma migrate and prisma db seed read the same file as before.

Do I need to change my migrations?

No. The upgrade moves the datasource URL into prisma.config.ts and the CLI applies the existing migrations from migrations.path as before. The pull request leaves prisma/migrations untouched, and the sandbox run applies all of them to a fresh database to prove it.

Where does the generated client live now?

Under the output path set on the prisma-client generator, src/generated/prisma in this layout, not in node_modules. The agent adds it to .gitignore and relies on the existing postinstall script that runs prisma generate, so a fresh clone generates it on install.

Why did migrate dev stop seeding?

In version 7, prisma migrate dev and prisma migrate reset no longer run the seed, and migrate dev and db push no longer run generate. The agent checks each script: this project's dx:next already runs db-seed explicitly and prebuild already runs generate first, so they keep working.

What changes at runtime that the diff does not show?

Connections go through the pg driver, whose pool defaults differ from the engine's, and TLS certificates are validated rather than ignored. The pull request names both so a reviewer can add ssl or pool options to the adapter before production sees the change.

More Prisma jobs

More jobs like this: Upgrade dependencies weekly

Keep reading