# Prisma CLI
> Next-generation ORM for Node.js and TypeScript

## Summary
CLI for the Prisma ORM. Manages database schemas, runs migrations, generates type-safe clients, seeds data, and provides a visual database browser (Prisma Studio).

## Capabilities
- Generate type-safe database client from Prisma schema
- Create and run database migrations
- Introspect existing databases to generate Prisma schema
- Seed databases with initial or test data
- Launch Prisma Studio for visual database browsing
- Validate and format Prisma schema files
- Support for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB, and CockroachDB

## When to Use
- Managing database schemas and migrations in Node.js/TypeScript projects
- Need a type-safe ORM with auto-generated client code
- Introspecting an existing database to generate a schema
- Want a visual database browser without installing separate tools

## When NOT to Use
- Not using Node.js or TypeScript
- Working with non-supported databases
- Prefer writing raw SQL without an ORM layer

## Key Flags
- `migrate dev`: Create and apply migrations in development
- `migrate deploy`: Apply pending migrations in production
- `generate`: Generate Prisma Client from the schema
- `db push`: Push schema changes directly without creating a migration
- `studio`: Open Prisma Studio visual database browser
- `db pull`: Introspect the database and update the Prisma schema

## Usage Patterns
### Initialize Prisma in a project
```
prisma init --datasource-provider postgresql
```
Sets up Prisma with a PostgreSQL datasource and creates schema.prisma

### Create and apply a migration
```
prisma migrate dev --name add-users-table
```
Creates a named migration from schema changes and applies it

### Generate the Prisma Client
```
prisma generate
```
Generates the type-safe client from the current schema

### Open visual database browser
```
prisma studio
```
Launches Prisma Studio in the browser for viewing and editing data

## Input / Output
- **stdin**: Accepts interactive input for migration naming and confirmations
- **stdout**: Migration status, generation output, and schema validation results
- **stderr**: Error messages, schema validation errors, and migration conflicts

## Installation
- **npm**: `npm i -g prisma`

## Related Tools
- [railway](/tools/railway) (complementary): Railway can host Prisma-backed apps with managed databases
- [litecli](/tools/litecli) (complementary): litecli provides interactive SQLite access for Prisma SQLite databases
- [pgcli](/tools/pgcli) (complementary): pgcli provides interactive PostgreSQL access alongside Prisma

---
Source: https://littlescripts.sh/tools/prisma
