W
Wasp2w ago
JakeLoew

Roll back migration without destroying data

I have added a new model to my schema.prisma and run a single migration. I'd like to roll back my db to the previous migration, but it seems I am unable to do so without resetting the schema and dropping all my data, even though the table is not populated with any data. How can I migrate backward non-destructively? Wasp version ^0.15.0.
2 Replies
kapa.ai
kapa.ai2w ago
Hi @JakeLoew. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Unfortunately, the knowledge sources provided do not contain specific information about rolling back migrations non-destructively in Wasp without destroying data. The available information mostly covers basic database commands and migration processes, but doesn't address the specific scenario you're asking about. However, I can provide some general guidance based on the available information: 1. Wasp uses Prisma for database management, so Prisma's migration capabilities apply here. 2. The wasp db migrate-dev command is used to apply migrations, but there's no explicit mention of a rollback command in the Wasp CLI Database Commands. 3. Prisma itself doesn't have a built-in rollback feature for migrations. Typically, to undo a migration, you would need to create a new migration that reverses the changes. Given the limitations in Wasp's current migration tooling, you might need to consider one of these approaches: 1. Create a new migration that removes the changes introduced by your previous migration. 2. Manually modify your database schema to revert the changes. 3. If possible, use Prisma's prisma migrate reset command, but be aware that this will clear your database. For a more precise answer or a non-destructive rollback method specific to Wasp, you might want to consult the Wasp documentation or reach out to the Wasp community for the most up-to-date information on handling this scenario. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @JakeLoew, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
JakeLoew
JakeLoewOP2w ago
Ok. I think I see how I can accomplish what I need by using --create-only and writing the SQL myself so it will be non-descructive, then applying it. Thank you Mr. Kapa AI.

Did you find this page helpful?