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

Allow a database to adopt reversible migrations after initially using non-reversible ones #3598

Open
kyle-leonhard opened this issue Nov 6, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@kyle-leonhard
Copy link

kyle-leonhard commented Nov 6, 2024

Is your feature request related to a problem? Please describe.

At the start of a project, stability isn't usually important so developers take the expedient path. Later, as the project gains adoption, stability, things like being able to rollback changes become important.

This applies to me and my usage of sqlx migrations. Initially, I used non-reversible migrations. After all, I could just blast my DB and star over, so why write reversible ones. Now, things are more serious and I'd like to use reversible migrations, but I can't. The sqlx CLI prevents me from applying a reversible migration once I have non-reversible ones - the -r flag is ignored. My understanding is that this is intentional - #2664

Describe the solution you'd like

Running sqlx migrate -r something should create a reversible migration even if prior migrations are not. sqlx migrate revert should do the right thing and prevent me from trying to revert a non-reversible migration. I'm ok if all migrations going forward are automatically inferred to be reversible.

At the very least, it'd be nice to see a warning or even fail a command rather than ignore the -r flag: #2664

Describe alternatives you've considered

Manually combining all of my existing migrations and starting from scratch. But I'm not sure how to do that while maintaining an existing database, short of hacking the _migration table myself.

@abonander
Copy link
Collaborator

#3597 (comment)

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