Skip to content

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

@kyle-leonhard

Description

@kyle-leonhard

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions