-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add the possibility to skip migrations #3846
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
base: main
Are you sure you want to change the base?
Conversation
b06c41e to
511b44b
Compare
abonander
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay in review. I'm happy to land this change as it's an oft-requested feature, but it needs rebasing and there's a couple design nits. Depending on when you get to this, there may not be time to land it in 0.9.0.
However, if we modify it to not be a breaking change (which is quite easy), then this can land in any future release.
sqlx-cli/src/lib.rs
Outdated
| ) | ||
| .await? | ||
| } | ||
| MigrateCommand::Skip { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to put this under an override subcommand. That way, it's clear that what you're doing is potentially dangerous, and we can add other useful commands there as well (such as forgetting already-run migrations or updating their hashes).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I adapted it, hope I understood you correctly.
sqlx-core/src/migrate/migrate.rs
Outdated
| fn apply<'e: 'm, 'm>( | ||
| &'e mut self, | ||
| migration: &'m Migration, | ||
| skip: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of modifying the signature of this method, which is a breaking change, we can add a new method with a provided body that returns Err(MigrateError::SkipNotSupported) by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
f135644 to
c92227b
Compare
|
Sorry for the delay also from my side and thank you for the feedback! I tried to address your findings. |
387c35f to
0ffb6a9
Compare
0ffb6a9 to
856519c
Compare
Does your PR solve an issue?
fixes #3841
Is this a breaking change?
Yes, it modifies the public trait
Migrate.