Execute a fault-tolerant installation and configuration of Prisma ORM v7.3.0 architecture with MySQL.
To install this skill, run the following command:
npx skills add https://github.com/arthur-oliveira-oficial/skills/tree/main/installation-prisma-7.3-database-mysql --skill installation-prisma-7.3-database-mysql
Before using this skill, make sure you have:
After installation, the skill will be available in the system. See the sections below for detailed instructions on how to use this skill to configure Prisma ORM v7.3.0 with MySQL.
ROLE: Senior Backend Engineer (TypeScript/SQL Specialist).
OBJECTIVE: Execute a fault-tolerant installation and configuration of Prisma ORM v7.3.0 architecture.
CONSTRAINT LEVEL: CRITICAL. Strict adherence to Prisma v7 breaking changes (ESM-native, Driver Adapters, Config Files) is mandatory.
Before execution, assert the following runtime environment parameters. Abort if non-compliant.
Context: Prisma v7 operates natively as an ES Module. Legacy CommonJS patterns are deprecated.
Manifest Configuration (package.json):
Inject the module type directive.
"type": "module"
Compiler Configuration (tsconfig.json):
Enforce modern module resolution strategies.
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "bundler",
"target": "ES2023",
"strict": true,
"esModuleInterop": true
}
}
Directive: Pin strict versions to prevent drift. Use the MariaDB adapter for optimized MySQL throughput.
Command Sequence:
# Core Dependencies
npm install prisma@7.3.0 @types/node --save-dev
# Runtime & Adapter Dependencies
npm install @prisma/client@7.3.0 @prisma/adapter-mariadb dotenv
Context: CLI configuration is now decoupled from environment variables via prisma.config.ts.
Scaffold Project:
npx prisma init --datasource-provider mysql --output ../generated/prisma
Configuration Entry Point (prisma.config.ts):
Action: Create file at project root.
Requirement: Explicit dotenv loading is mandatory; the CLI no longer auto-loads .env.
import 'dotenv/config';
import { defineConfig, env } from 'prisma/config';
export default defineConfig({
schema: 'prisma/schema.prisma',
datasource: {
url: env('DATABASE_URL'),
},
});
Environment Variables (.env):
Action: Define connection parameters.
DATABASE_HOST="localhost"
DATABASE_USER="root"
DATABASE_PASSWORD="password"
DATABASE_NAME="mydb"
# Connection String Construction
DATABASE_URL="mysql://root:password@localhost:3306/mydb"
File: prisma/schema.prisma
Critical Changes:
generator client {
provider = "prisma-client"
output = "../generated/prisma"
}
datasource db {
provider = "mysql"
}
Directive: Generate the type-safe client based on the schema definition.
npx prisma generate
WARNING: The migrate dev pipeline no longer triggers generation automatically. This step must be explicit.
Context: Direct instantiation is deprecated for high-performance contexts. Use the PrismaMariaDb adapter.
File: lib/prisma.ts
import "dotenv/config";
import { PrismaMariaDb } from '@prisma/adapter-mariadb';
import { PrismaClient } from '../generated/prisma/client';
// Initialize Driver Adapter
const adapter = new PrismaMariaDb({
host: process.env.DATABASE_HOST,
user: process.env.DATABASE_USER,
password: process.env.DATABASE_PASSWORD,
database: process.env.DATABASE_NAME,
connectionLimit: 5 // Optimization: Connection pooling limit
});
// Instantiate Client with Adapter
export const prisma = new PrismaClient({ adapter });
Audit your implementation against these forbidden patterns: