Open unidesigner opened 1 year ago
Hi Stephan,
I suppose it is theoretically possible. But allowing it could lead to unwanted results, like replacing data that shouldn't be, or applying changes based on an older data structure that is no longer appropriate for the current data structure.
I am still curious about your use case. Can you elaborate on it?
Counter proposal: How would you react if I told you that the "reapply" command can do all the "down" migrations and then reapply from the desired migration up to the last one? And if you do not want to apply to the last migration, we can think of a parameter called "--to" to reapply up to the migration of your choice (which should at least be after the down migration).
Hi David,
I understand that this would not be optimal in terms of data integrity. My use case is just convenience for my dev setup. I'm working on developing a new data model, and I'm generating the migration files using an other scripts. As I'm changing the model, I may discover that I need to make a slight change to an old migration, e.g. adding a field etc., and I just regenerate the old migration file. Migration files that come afterwards are still fine, as they normally work on other tables. The migrations I generate are generally update statements.
I think your suggested proposal would indeed work. Applying the down migration to my migration of interest (during development, I usually do not implement the down migration, so it would be just a skip operation). For my usecase, it's also ok to just reapply all the migration that come after my modified migration. Having a --to parameter would be nice.
I have a use case that I sometimes need to rerun/reapply a single old migration because I'm modifying the migration during development. Would it be feasible to add a 'reapply' command that runs the corresponding 'down' migration and applies the single old migration?