Prisma Data Migrations is a library (v1.6.0) that fills the gap in Prisma ORM by adding support for post-migration data scripts alongside schema migrations. It provides a CLI tool for initializing configuration, generating typed migration contexts, and executing scripts within database transactions. Unlike Prisma's built-in migration system which only handles schema changes, this package enables data seeding, transformations, and cleanup after schema migrations. Active development with monthly releases. Key differentiator: seamless integration with Prisma's existing migration folder structure, TypeScript-first, and atomic transaction support.
npm install prisma-data-migrationsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows full setup: install, init config, generate typed migrations, create a post-script with Prisma transaction, and execute via CLI.
Always use prisma.$transaction() to wrap your migration logic. Use run:postscript command to re-run after failure.
Rename the script file to post.ts (or .js, .sh) in the migration folder.
Skip this step if you don't use prismaSchemaFolder. Manual copying of schema.prisma is also supported.
Install ts-node: npm install ts-node --save-dev
Update import paths to match the new pattern with the migration folder name.
Run npx prisma-dm generate after creating migration folders.
Rename your script to post.ts (or .js, .sh) and place it directly in the migration folder.
Install locally: npm install prisma-data-migrations --save-dev, then use npx prisma-dm.
Access models via the prisma parameter inside the transaction callback, not via the outer PrismaClient instance.