Prisma migrate deploy only first N migrations
Is there a way to run
prisma migrate deploy
for only first n migrations?1 Reply
You chose to compile with the bot. One moment while I piece together your answer…
Currently, Prisma doesn't have a built-in feature to run
prisma migrate deploy
for only the first N migrations. The migrate deploy
command is designed to apply all pending migrations to your database.
There are a few workarounds that users have suggested:
1. Temporarily move migration files: You can temporarily move the migrations you don't want to apply to another directory, run prisma migrate deploy
, and then move them back when you're ready to apply them.
2. Use Git checkout: You can checkout a specific commit that contains only the migrations you want to apply:
3. Third-party solutions: Some community members have developed libraries like Prisma Data Migrations that enhance Prisma's migration system and allow migrating to specific migrations.
There is an open feature request for this functionality in the Prisma GitHub repository: Add option to migrate up to a specific version. The suggested implementation would be something like:
This feature would be particularly useful for:
- Testing migrations before applying them to production
- Working with legacy datasets
- Implementing the expand and contract pattern for migrations
- Handling irreversible migrations (like drops)
If this feature is important to you, consider adding a 👍 to the GitHub issue to help prioritize it.
Migrate Up/Down to specific migrations
Add option to migrate up to a specific version