This skill provides comprehensive guides for configuring Prisma ORM with multiple database providers including PostgreSQL, MySQL, and SQLite. It's suitable for developers looking to initialize a new Prisma project, switch database providers, or troubleshoot connection issues.
$ npx skills add https://github.com/prisma/skills --skill prisma-database-setupThis skill provides step-by-step configuration guides for Prisma ORM across seven supported database providers: PostgreSQL, MySQL, SQLite, MongoDB, SQL Server, CockroachDB, and Prisma Postgres. It covers datasource setup, driver adapter installation, Prisma Client generation, and environment variable configuration for each provider. The skill helps developers initialize new projects, migrate between databases, troubleshoot connection issues, and set up database-specific features. It includes required system prerequisites (Node.js 20.19.0+, TypeScript 5.4.0+), provider-specific schema configurations, and adapter selection guidance to ensure proper database connectivity and performance.
Install using the command `npx skills add https://github.com/prisma/skills --skill prisma-database-setup`.
Initializing a new Prisma project
Switching database providers
Configuring connection strings and environment variables
Troubleshooting database connection issues
$ npx skills add https://github.com/prisma/skills --skill prisma-database-setupgit clone https://github.com/prisma/skillsCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Generate a step-by-step guide for setting up Prisma ORM with [DATABASE_PROVIDER] for a [COMPANY] project in the [INDUSTRY] industry. Include commands for initializing Prisma, configuring the schema.prisma file, and testing the database connection. Assume we're starting from scratch. Use [DATABASE_URL] as the connection string placeholder.
### Prisma ORM Setup Guide for PostgreSQL
**1. Initialize Prisma in Your Project**
Run the following command in your terminal to install Prisma and its CLI:
```bash
npm install prisma @prisma/client --save-dev
```
**2. Initialize Prisma Schema**
Generate the Prisma schema file:
```bash
npx prisma init
```
**3. Configure `schema.prisma`**
Edit the generated `prisma/schema.prisma` file to include your PostgreSQL connection and schema:
```prisma
// schema.prisma
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model User {
id Int @id @default(autoincrement())
name String
email String @unique
}
```
**4. Set Up `.env` File**
Create a `.env` file in your project root and add your PostgreSQL connection string:
```env
DATABASE_URL="postgresql://postgres:password@localhost:5432/mydb?schema=public"
```
**5. Apply the Database Migration**
Run the migration to sync your schema with the database:
```bash
npx prisma migrate dev --name init
```
**6. Test the Connection**
Verify the setup by creating a simple test script in `index.js`:
```javascript
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
async function main() {
const users = await prisma.user.findMany();
console.log(users);
}
main()
.catch(e => {
throw e;
})
.finally(async () => {
await prisma.$disconnect();
});
```
Run it with:
```bash
node index.js
```
**Troubleshooting Tips:**
- Ensure your database server is running and accessible.
- Verify the `DATABASE_URL` in `.env` is correct.
- Check Prisma logs for errors during migration.Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan