Registry / devops / prisma-migration-migrator

prisma-migration-migrator

JSON →
library0.0.40jsnpmunverified

A utility wizard that replaces Prisma's migration engine with Knex, allowing developers to use Prisma as ORM while leveraging Knex's migration engine for running migrations. Version 0.0.40 is the latest, with irregular release cadence. Key differentiator: combines Prisma's schema and DDL auto-generation with Knex's programmatic migration capabilities, enabling data migrations and more control over migration execution. Currently in early development, tested mainly with PostgreSQL, with limited support for MySQL 8.x. Includes a setup script that configures Knex, creates sync scripts, and adds npm scripts for migration generation and application. Not recommended for production use.

npm install prisma-migration-migrator
INSTALL
IMPORT
SIG · PRISMA-MIGRATION-M
P
prisma-migration-migrator
devopsjavascriptv0.0.40
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

setup (via npx)
npx prisma-migration-migrator
npm install prisma-migration-migrator --save-dev (package is not meant to be installed as a dependency, only used via npx)
This package is a CLI tool intended to be run with npx, not installed as a library. It sets up Knex migrations alongside Prisma.
Prisma schema path argument
npx prisma-migration-migrator --schema=./prisma/schema.prisma
npx prisma-migration-migrator ./prisma/schema.prisma (incorrect usage, use --schema flag)
The optional second parameter is for the schema path, but it's passed as --schema=path or --schema path.

Shows the complete setup workflow: install dependencies, run the npx wizard, sync migrations, generate new ones, and apply them.

# Ensure you have a Prisma project set up with migrations npm install knex dotenv pg # Run the migrator setup (do not install the package)npx prisma-migration-migrator # The script will create knexfile.mjs, add migration scripts to package.json, and modify Prisma schema. # After setup, sync existing Prisma migrations with Knex: npm run migration:sync # Generate a new migration (this combines Prisma DDL and custom Knex logic): npm run migration:generate # Apply pending migrations: npm run migrations:apply # Now you can manage migrations with Knex while keeping Prisma as ORM.
Debug
Known issues
breakingnpx prisma-migration-migrator runs without installing the package. Installing it locally may lead to running an outdated or inconsistent version.
fix
Always use npx to ensure you get the latest version: npx prisma-migration-migrator
affects: >=0.0.0
gotchaThe setup script modifies your Prisma schema to ignore Knex migration tables. This can cause conflicts if you later attempt to revert to Prisma's native migrations.
fix
Before switching back to Prisma migrations, manually remove the added models from schema.prisma and reset the migration history.
affects: >=0.0.0
gotchaDatabase compatibility is limited. Tested primarily with PostgreSQL. MySQL 8.x works for basic migrations but DDL generation may fail on MySQL 5 and SQLite.
fix
Stick to PostgreSQL if you need full DDL generation support. For other databases, manually write DDL in Knex migrations.
affects: >=0.0.0
deprecatedThe package is a side project with no stable release. The README explicitly warns against production use.
fix
Do not use in production. Consider alternatives like Prisma's native migrations or using Knex exclusively if you need programmatic migrations.
affects: <1.0.0
breakingThe setup script may fail if your project already has a knexfile.mjs. The script does not always handle pre-existing configurations gracefully.
fix
Back up your existing knexfile.mjs before running the setup. Use --force to overwrite if needed.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'knex'
Knex is not installed as a dependency (the package uses npx but knex is required at runtime).
fix
Run npm install knex in your project before calling the migrator.
Error: knexfile.mjs already exists. Use --force to overwrite.
The setup script detects an existing knexfile from a previous run or manual creation.
fix
Delete or rename the existing knexfile.mjs, or run the command with --force: npx prisma-migration-migrator -- --force
Error: Migration 'XXXXX' already exists, but it's not applied. knex cannot sync.
After syncing, there's a mismatch between Prisma's migration history and Knex's expected state.
fix
Run migration:sync again after ensuring all Prisma migrations are applied. You can manually sync by marking existing migrations as applied via knex migrate:make and then manually inserting records into the Knex migration table.
Upgrade
Version history
0.0.40latest on npm
Audit
Dependencies
knexrequiredRequired as the migration engine
pgrequiredPostgreSQL driver for Knex
dotenvoptionalRecommended to load environment variables
prisma-diff-to-knex-migrationoptionalOptional tool to generate Knex migrations from Prisma SQL DDL
Agent activity
9 hits · last 30 days
node
8
Resources
prisma-migration-migrator — npm install prisma-migration-migrator · libregistry