Closed insano10 closed 1 month ago
There isn't a mechanism for merging existing migrations at the moment, so you'd have to manually update the schema table at the moment.
I do think having this as a feature would be a good idea. I've run into this scenario myself as well. One strategy could be to have a helper function where you can provide the ids for the start/end migrations for a list if migrations to be merged and then just concatenate them separated by --;;
. This should produce a single migration file that behaves the same way, and then it could also run the sql query that updates the migrations table to match the new numbering scheme.
I'll have a think on this.
A complication is the potential mixture of code-based and SQL based migrations. Currently I have a mixture of the 2 so creating a single baseline migration would have to be a code-based one.
It's still definitely possible, maybe something like:
Yeah that sounds like it should work. Compressing SQL patches into a single migration could be a standalone step, and then if there only SQL migrations you just compress them and update the migration history. If there are also code migrations then the code migration would be the baseline and you'd do the steps you outlined.
I’ve experienced the same need for this feature, and I think it would be very useful. Is anyone currently working on this? If not, I’d be happy to submit a PR to help address it.
I don't think anybody is looking at this at the moment. If you'd be up to do a PR that would be very welcome!
Yeh sorry I've been too busy to progress this since opening the issue 🙈 if you'd like to implement this that would be fab.
Just pushed out 1.6.1 with the features, amazing work @Gwonwoo-Nam !
Can you please suggest a strategy for compressing a large timeline of migrations?
Given a large accumulation of migrations I would ideally like to create a single migration that contains all the combined schema changes so far and have that be the new latest applied patch in the schema table.
Is there any provision to do this through migratus commands, or would it involve manually updating the schema table data?