This document outlines the changes made to upgrade from Prisma v5.22.0 to Prisma v7.2.0 in the new-lil-sprouts SolidJS application.
Migration Date: [Current Date] Previous Version: Prisma v5.22.0 New Version: Prisma v7.2.0
Prisma v7 introduces several breaking changes, primarily:
- ESM-only architecture - No longer supports CommonJS
- Required output path - Generator must specify where to output the client
- Database adapter pattern - PostgreSQL connections now use adapters
- Removed
urlfrom datasource - Connection strings now passed via PrismaClient constructor - Updated provider name - Changed from
prisma-client-jstoprisma-client
Added:
@prisma/adapter-pg@^7.0.0- PostgreSQL adapter for Prisma v7pg@^8.13.1- PostgreSQL driver@types/pg@^8.11.10- TypeScript types for pg
Updated:
prisma:^5.22.0→^7.0.0@prisma/client:^5.22.0→^7.0.0
Before:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}After:
generator client {
provider = "prisma-client"
output = "../src/generated/prisma-client"
}
datasource db {
provider = "postgresql"
}Changes:
- Updated
providerfrom"prisma-client-js"to"prisma-client" - Added required
outputfield to specify client generation location - Removed
urlfield from datasource (now handled in runtime config)
Key Changes:
- Import from generated client location:
"../generated/prisma-client/client.js" - Added PostgreSQL connection pool using
pgpackage - Created Prisma adapter using
@prisma/adapter-pg - Pass adapter to PrismaClient constructor
Before:
import { PrismaClient } from "@prisma/client";
return new PrismaClient({
log: process.env.NODE_ENV === "production" ? ["error", "warn"] : ["query", "error", "warn"],
});After:
import { PrismaClient } from "../generated/prisma-client/client.js";
import { Pool } from "pg";
import { PrismaPg } from "@prisma/adapter-pg";
// Create PostgreSQL connection pool
const pool = new Pool({ connectionString: dbUrl });
// Create Prisma adapter for PostgreSQL
const adapter = new PrismaPg(pool);
// Create Prisma Client with adapter (Prisma v7 requirement)
return new PrismaClient({
adapter,
log: process.env.NODE_ENV === "production" ? ["error", "warn"] : ["query", "error", "warn"],
});Updated all Prisma type imports to use the new generated client location:
Files Updated:
src/lib/care-schedules.tssrc/lib/family-members.tssrc/lib/session-reports.ts
Before:
import type { DayOfWeek, RecurrencePattern } from "@prisma/client";After:
import type { DayOfWeek, RecurrencePattern } from "../generated/prisma-client/client.js";Updated SSR and optimization configs to exclude the new adapter packages:
Before:
ssr: {
external: ["@prisma/client", ".prisma/client"],
noExternal: [],
},
optimizeDeps: {
exclude: ["@prisma/client", ".prisma/client"],
},After:
ssr: {
external: ["@prisma/client", "@prisma/adapter-pg", "pg", "~/generated/prisma-client"],
noExternal: [],
},
optimizeDeps: {
exclude: ["@prisma/client", "@prisma/adapter-pg", "pg", "~/generated/prisma-client"],
},Added missing service relation include in generateSessionsFromSchedule:
const schedule = await db.careSchedule.findUnique({
where: { id: scheduleId },
include: {
children: true,
service: true, // Added to fix service rate calculation
},
});- ✅ Updated package.json dependencies
- ✅ Ran
pnpm installto install new packages - ✅ Updated Prisma schema with new generator config and removed datasource URL
- ✅ Updated database client to use adapter pattern
- ✅ Updated all type imports across the codebase
- ✅ Updated Vite configuration for new packages
- ✅ Ran
pnpm prisma:generateto generate new client - ✅ Fixed missing service relation in care-schedules
- ✅ Verified TypeScript compilation (no errors)
- ✅ Ran production build successfully
The Prisma Client is now generated to:
src/generated/prisma-client/
├── browser.ts
├── client.ts
├── commonInputTypes.ts
├── enums.ts
├── models.ts
├── internal/
└── models/
Note: The src/generated/ directory should be added to .gitignore if not already present.
No changes to environment variables required. The application continues to use:
DATABASE_URL- PostgreSQL connection string (including SSL certificate path resolution)
- ✅ TypeScript compilation passes
- ✅ Production build succeeds
- Database migrations run successfully
- Application starts without errors
- Database queries work correctly
- All CRUD operations function properly
- SSL certificate path resolution works in production
If you need to rollback to Prisma v5:
- Revert
package.jsonchanges - Run
pnpm install - Revert
prisma/schema.prismato addurlfield back and useprisma-client-js - Revert
src/lib/db.tsto remove adapter pattern - Revert all type imports to use
@prisma/client - Revert
app.config.tschanges - Run
pnpm prisma:generate - Delete
src/generated/directory
- Node.js Requirement: Prisma v7 requires Node.js >= 20.19.0 (we use Node.js >= 22)
- TypeScript Requirement: Prisma v7 requires TypeScript >= 5.4.0
- Performance: Prisma v7 is built in TypeScript (Rust-free), resulting in faster queries and smaller bundle sizes
- Compatibility: Fully compatible with SolidStart and SSR applications
- MongoDB: Prisma v7 does not yet support MongoDB (we use PostgreSQL, so no issue)
✅ Migration Complete
The application has been successfully upgraded to Prisma v7 with all builds passing and no TypeScript errors.