Add a `prisma.$reset()` function as shortcut to running `prisma migrate reset`
See original GitHub issueProblem
prisma migrate reset
is used heavily for testing. I want a prisma.$reset()
function added to prisma client as super easy shortcut to reset the database.
Suggested solution
I’ve added this to our Blitz adapter and it’s super nice in Jest tests:
beforeEach(async () => {
await db.$reset()
})
Optionally this command could be disabled/fail if process.env.NODE_ENV === 'production'
Alternatives
None
Issue Analytics
- State:
- Created 3 years ago
- Reactions:51
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Prisma Migrate | Database, Schema, SQL Migration Tool
Prisma Migrate is a database migration tool available via the Prisma CLI that integrates with Prisma schema for data modeling.
Read more >Prisma Migrate in development and production
Reset the development database. You can also reset the database yourself to undo manual changes or db push experiments by running: $npx prisma...
Read more >Prisma CLI Command Reference
migrate reset. For use in development environments only. This command deletes and recreates the database, or performs a 'soft reset' by removing all...
Read more >Developing with Prisma Migrate
You should expect to reset your database in a development environment - for example, if you regularly switch between branches that have different...
Read more >Migration troubleshooting in development - Prisma
If Prisma Migrate detects a migration history conflict when you run prisma migrate dev , the CLI will ask to reset the database...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As a workaround, you can copy the code we use in Blitz for this: https://github.com/blitz-js/blitz/blob/canary/packages/core/src/prisma-utils.ts
Which you can then use like this:
FYI I’m migrating from sequelize to prisma and at the moment performance using
transaction
+executeRaw
method by @rsaryev (https://gist.github.com/rsaryev/65884be2d8992552e9a603fefabaecb3) is close to sequelize’s and much more faster (10s per reset in my jest setup) than spawningmigrate reset
cli each time .