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.
Migrate Database
Creates SQL migrations and applies them to your database.
Generate Client
Generates PHP classes. (Runs `prisma generate` internally).
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
GUIA 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
PrototypingUpdates the DB without creating a migration file. Good for quick tests.
npx prisma db push
Deploy
ProductionApplies 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