Migrations with Prisma Migrate
A migration is a versioned, applied change to your database schema. Prisma Migrate generates and runs the SQL for you, based on the differences it sees in schema.prisma.
npx prisma migrate dev --name init
This command:
- Compares your schema to the database's current state.
- Generates a plain SQL migration file (you can open and read it, it's just
CREATE TABLE,ALTER TABLE, and so on). - Applies it to your database.
- Regenerates Prisma Client so your code's types match the new schema.
Each migration lives in prisma/migrations/<timestamp>_init/migration.sql, committed to version control alongside your code, exactly like the rest of your app's history.
Inspecting your data
npx prisma studio
Opens a local, visual browser for your database, handy for checking that a migration or query did what you expected.