Migrations Rollback #1339
Replies: 63 comments 92 replies
|
I would love a migrate down option as well. My current approach is:
|
|
If implementing an automated rollback script will take a big effort, I'd like to have a way to opt in for a manual rollback script for the time waiting for the feature. Being able to review and commit a rollback script like |
|
I second that - not implementing migrations rollback/resetting is a huge omission. It's an awful pain to correct your migrations when developing schema change in a single PR doing changes on the way, since you have to delete or merge the migration files, modify the journal, revert the DB state manually and whatnot. |
|
Can I pay Drizzle Team to add this? |
|
Please add a rollback option for migrations :) would be awesome. |
|
Don't have it yet? Wow... it's so essential! |
|
agree |
|
Yeah this would be huge |
|
Needing this feature so badly |
|
Hope it releases soon |
|
Just need this feature to use in production :( |
|
Can we get any update on this from the drizzle team? I've posted the same in Discord, but haven't received a response. Be good to know if this is being worked on or not. Not, is fine, we'd just need to work on some approach that builds the reverse migrations using something else, but I'd be keen to know if it's something in the pipeline just to avoid recreating the wheel here. Please and thanks 🙏 |
|
+1 on this, this is the only thing preventing us from using Drizzle for production as migration rollback can be crucial when deploying. |
|
rollback pleaseeeee... |
|
Any updates guys? 👉👈 |
|
Absolutely love drizzle, but my team won't adopt it prod without this feature 🙏 |
|
I'll pay for this feature |
|
Please, this is a fundamental part of any migration solution. Not having the possibility to rollback, creates a massive headache if one person messes up one migration for whatever reason. |
|
It's been two years, why there is no response to this most asked feature? And also curious to know that how people are managing rollback today? |
|
The strategy that feels like the best path forward would be a phased approach i would think
|
|
Something really cool is coming |
|
I have read this blog and looks promising, Anyone has tried this manual approach? https://app.studyraid.com/en/read/11288/352162/running-and-reverting-migrations |
|
Atlas has integration with drizzle so probably you can achieve down migration using it. it can generate migrations based on a drizzle schema so it should work very well but I haven’t tried it out yet |
|
@Nishchit14 I am using the manual method and I just put my rollback script in this comment - #2352 (comment) |
|
I have a concern that I can't seem to find anyone address yet - which kind of ties into the issue with the migrations being .sql files - but the migration files are being passed by dir/glob, and the schema file is being referenced via path. Simple fix for the dir glob would be to expose And whilst the schema could definitely be passed as it currently is (for use in ts-node / tsx / etc. or even NodeJS itself now) - passing the file directly would ensure it's bundled correctly would be a most welcome addition. My specific use case is that I don't tend to yolo migrations by putting sql files in a dir, (maybe using tsc to preserve dir structure), and then 'pushing' those migrations to dev / staging / live or whatever env. Rather I usually create a little CLI app that connects to the DB [which is compiled & bundled] (from local machine / GH actions / on-prem server - wherever) and then trigger the migrations using exposed methods there - managed to implement everything most ORMs have, transactions (each/all) included. Those packages above are a step in the right direction for sure. It's what I've been doing, just wrapping the up/down sql in class methods. Yet something doesn't sit right with me either.. since drizzle knows which dialect its using, instead of raw sql outputs it could either use it's own drizzle client to execute those queries in a more structured way. Can't wait until drizzle releases 1st class support for it, and hope they cover all bases. Personally never seen a migrations system without up/down/revert/dry-run etc. But would love to see a divergence (or at least extra option) to use an array of migrations and a schema file directly instead of paths which cause all kinds of havoc. I know the drizzle team have a lot on their hands, so no rush, since we all seem to have worked around it in our own ways, but 1st class support would be ideal 🙏 keep it up guys. And let me know if you need a hand with anything |
|
we still do not have it in 2026? come on guyz! |
|
This is crazy. 2.5 years since the issue was created for one of the most basic features of an orm |
|
I ran into this problem while using Drizzle and ended up building drizzle-rollback. https://github.com/atralvarez/drizzle-rollback It generates rollback migrations from existing Drizzle migrations, making it easier to revert schema changes when needed. I'd love to hear feedback from anyone dealing with migration rollbacks in production, and whether this covers your use cases or if there are missing features. |

Uh oh!
There was an error while loading. Please reload this page.
Hi #drizzle-team & community folks 👋
I'd like to suggest something that I believe more people might be looking for. Is there any plan for rollback migrations?
My day-to-day workflow
Because Drizzle currently doesn't support a way to rollback migrations I'm using a custom solution (hopefully temporary) with migrate with a specific
Dockerfileconfigured and a more painful way to configure/deploy to run our migrations, which might be slightly painful sometimes:*.up.sqlthe migration script;*.down.sqland manually add a rollback;Dockerfile+run.shscript that doesn't look as pretty as I would like; 😅I was wondering if on next releases, there will be any sort migration rollback like migrate does.
This would benefit many developers and wouldn't be a breaking change by keeping everything else working.
Possible solution:
drizzle-kit generatecommand;*.down.sql;drizzle-kitit cheks for the migrations table and identifying the latest migration ID to match with a<migration_name>.down.sqlscript on the folder to be executed otherwise exit;drizzle-kit rollback:*/drizzle-kit undo:*command;The future
Using Drizzle is being a breazy so far (coming from Knex) and I wanna see what things going far beyond the rest of the community.
Let's see how the community will (or not) react to this idea (calling for help) and also the core team.
All reactions