Prisma migrate
Prisma Migrate uses Prisma schema changes to automatically generate fully customizable database schema migrations
1model User {2 id Int @id @default(autoincrement())3 email String @unique4 name String?5}
-- CreateTableCREATE TABLE "User" ( "id" SERIAL NOT NULL, "email" TEXT NOT NULL, "name" TEXT, PRIMARY KEY ("id"));
-- CreateIndexCREATE UNIQUE INDEX "User.email_unique" IN "User"("email");
Migrations are automatically generated so you don't have to write the SQL by hand.
Migrate generates SQL migrations, ensuring migrations will always result in the same database schema across environments.
Generated SQL migrations can be fully customized giving you full control over the exact changes.
Iteration
While prototyping you can create the database schema quickly using the prisma db push
command without creating migrations.
Quickly seed your database with data by defining a seed script in JavaScript, TypeScript or Shell.
Migrate detects database schema drift and assists you in resolving them.
Deployment
Migrate supports dedicated workflows for carrying out migrations safely in production.
Migrate can be integrated into CI/CD pipelines, e.g. GitHub Actions, to automate applying migrations before deployment.
Migrate keeps track of applied migrations and provides tools to detect and resolve conflicts and drifts between migrations and the database schema.
When using Prisma Migrate with Prisma Client, schema changes are type checked in your application code. This eliminates errors that arise when database schema changes require changes to the application code.
Prisma Migrate generates migrations based on changes in the Prisma schema – a human-readable declarative definition of your database schema. This allows you to focus on your desired database schema rather than the steps to get there.
With Prisma Migrate, generated migrations are tracked in your Git repository, allowing you to make changes to your database schema in tandem with your application code.
Prisma Migrate enables smooth collaboration with workflows that make it easy for teams to review and test database schema changes before going to production.
Prisma Migrate can be adopted in any existing project that uses PostgreSQL, MySQL, MariaDB, SQL Server, CockroachDB or SQLite.