Prisma Config
In Prisma ORM v7+, configuration moves beyond the package.json or schema.prisma limits. The prisma.config.ts file serves as the central, type-safe hub for your ORM setup.
The Configuration File
Create a file named prisma.config.ts in your project root. This file exports your configuration object using the defineConfig helper.
import { defineConfig, env } from "prisma/config";
import "dotenv/config";
export default defineConfig({
// Location of your Prisma Schema
schema: "prisma/schema.prisma",
// Migrations & Seeding configuration
migrations: {
path: "prisma/migrations",
seed: "tsx prisma/seed.ts",
},
// Database Connection
datasource: {
url: env("DATABASE_URL"),
},
});
Configuration Options
| Property | Type | Description |
|---|---|---|
| schema | string |
The relative path to your schema.prisma file.
|
| migrations.path | string | The directory where migration history and SQL files will be stored. |
| migrations.seed | string |
The terminal command to run your seed script (e.g., using tsx or node).
|
| datasource.url | string |
The connection string for your database. Use the env() helper to load this securely from environment variables.
|
Managing Environment Variables
Prisma v7 removes the automatic loading of .env files. You must explicitly import a loader like dotenv at the top of your config file.
import "dotenv/config";