Prisma Migration Checker is a CLI tool to check if new Prisma migrations can be applied safely to the database.
When you use Prisma in your web app, you might have encountered failed migrations when deploying the migrations to the production database. While Prisma has documented the methods to fix this issue, it's not easy and straightforward.
It'd have much better if you can check if the new migrations will succeed before actually deploying the migrations, say in your CI/CD pipeline. This is where Prisma Migration Checker comes to play.
Prisma Migration Checker is developed using Node.js and TypeScript. So you can install it from the NPM as follows
npm install -g @hyperjumptech/prisma-migration-checker
You need to provide two schema files which are the schema file with the new migrations and another schema file without the new migrations.
prisma-migration-checker --new <path_to_the_new_schema> --current <path_to_the_existing_schema>
Note that before running Prisma Migration Checker, you need to:
- have the database used in your prisma.schema running (Postgres, MongoDB, SQLite, etc).
To check if a schema.prisma file that was changed in a pull request, you can checkout first the schema.prisma from the main branch before running Prisma Migration Checker in your CI pipeline.
git show main:prisma/schema.prisma > prisma/schema-main.prisma
prisma-migration-checker --new prisma/schema.prisma --current prisma/schema-main.prisma
clone the repo.
if you want to use prisma-seeder
locally, you can build it by running npm pack --pack-destination ~
in the prisma-seeder
directory.
Then find the generated file on ~/hyperjumptech-prisma-seeder-0.0.3.tgz
(version is defined in package.json). Then update your package.json > dependences
"dependencies": {
...
"@hyperjumptch/prisma-seeder": "file:~/hyperjumptech-prisma-seeder-0.0.3.tgz",
...
}
then install dependencies using
npm install
then run this to start the package
./bin/dev --new <path_to_the_new_schema> --current <path_to_the_existing_schema> --database-url <url_of_the_database>
- Prisma Migration Checker will apply the current migrations to the database.
- It will then populate the database with fake data.
- Finally it will apply the new migrations from the new schema file.
MIT