Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rerun a single old migration #45

Open
unidesigner opened this issue Jul 17, 2023 · 2 comments
Open

Rerun a single old migration #45

unidesigner opened this issue Jul 17, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@unidesigner
Copy link

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?

@Odonno
Copy link
Owner

Odonno commented Jul 17, 2023

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).

@Odonno Odonno added enhancement New feature or request question Further information is requested labels Jul 17, 2023
@unidesigner
Copy link
Author

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.

@Odonno Odonno removed the question Further information is requested label Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants