LMS
DashboardAll Blogs

How to setup/migrate Prisma v7

A

Ali Raza

ali-raza-fa22
Created on: 10 Jan 2026
Last updated on: 10 Jan 2026

Prisma updated their version and previous version started to show warnings to migrate, don't worry, I got you covered. I will guide you through all the steps to migrate to new version.

I am assuming you have already initialized your application.

Step 1:

Install prisma latest version:

If you already have project and want to migrate, this will work too.

pnpm add -D prisma@latest @types/node @types/pg

and also update prisma client

pnpm add @prisma/client@latest dotenv

this will update your dependencies.

Step 2:

Update schema.prisma :

generator client {
  provider = "prisma-client"
  output   = "../lib/generated/prisma" // <-- where to save output, default is inside node_modules
}

datasource db {
  provider = "postgresql" // <--- or your provider
  // url      = env("DATABASE_URL") // <-- Remove this line
}

create new file named: prisma.config.ts in root of the project:

import "dotenv/config"; // <-- for type safety of env.DATABASE_URL

import { defineConfig, env } from "prisma/config";

export default defineConfig({
  schema: "prisma/schema.prisma", // <-- where is schema.prisma
  migrations: {
    path: "prisma/migrations" // <-- where to save migrations
  },
  datasource: {
    url: env("DATABASE_URL"),
  },
});

Step 3:

Install postgres adapter:

pnpm add @prisma/adapter-pg@latest pg 

and create/update lib/prisma.ts :

import { PrismaPg } from "@prisma/adapter-pg";
import { PrismaClient } from "./generated/prisma/client";

const globalForPrisma = global as unknown as {
  prisma: PrismaClient;
};

export const adapter = new PrismaPg({
  connectionString: process.env.DATABASE_URL,
});

const prisma = globalForPrisma.prisma || new PrismaClient({ adapter });

if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;

export default prisma;

That's it. All the remaining queries remain same.

Here's what each package does:

  • prisma - The Prisma CLI for running commands like prisma init, prisma db pull, and prisma generate

  • @prisma/client - The Prisma Client library for querying your database

  • @prisma/adapter-pg - The node-postgres driver adapter that connects Prisma Client to your database

  • pg - The node-postgres database driver

  • @types/pg - TypeScript type definitions for node-postgres

  • dotenv - Loads environment variables from your .env file

If you are new to prisma see How to add Prisma ORM to an existing project using PostgreSQL (15 min) | Prisma Documentation

I will also create blog about how to setup prisma for mongodb soon.

Tags:

prismaprismav7nextjs