Prisma Workflow

The database lifecycle consists of two main phases: Synchronization (Updating the DB) and Generation (Updating PHP Classes).

The Development Cycle

Whenever you modify schema.prisma, run these two commands in order.

1

Migrate Database

Creates SQL migrations and applies them to your database.

npx prisma migrate dev
2

Generate Client

Generates PHP classes. (Runs `prisma generate` internally).

npx ppo generate

Logic Rule: The PHP client relies on the artifacts created by the migration. Always run Migrate (1) before Generate (2) to ensure your PHP classes match your database structure.

Secondary Utilities

Prisma Studio

GUI

A visual interface to view and edit data in your database.

npx prisma studio

Format Schema

DX

Fixes indentation and alignment in your schema.prisma file.

npx prisma format

DB Push

Prototyping

Updates the DB without creating a migration file. Good for quick tests.

npx prisma db push

Deploy

Production

Applies pending migrations. Use this in CI/CD pipelines.

npx prisma migrate deploy

Reset Database

Destructive: Deletes the database, drops all data, and re-applies migrations from zero.

npx prisma migrate reset