golang-migrate / migrate

Database migrations. CLI and Golang library.
Other
14.48k stars 1.34k forks source link

Allow golang-migrate to continue even if it can't find the current version #1091

Open SJrX opened 1 month ago

SJrX commented 1 month ago

Is your feature request related to a problem? Please describe. This relates to my request in #556 but things have gotten much simpler. The tl;dr is that we have versioned containers (Kubernetes Jobs) that run when we do a deployment. We largely decouple our application version from our DB version, and because we are mongo most of our migrations are benign like adding a index, that works fine with previous versions.

When we need to rollback an application we run into an issue where the DB version in the DB is newer than what the container sees.

In #556 things were complicated because we were running it on container start up, and we worked around a lot of the challenges through a bunch of K8s hacks. However we are migrating our deployment scripts away from hacks to Argo CD, which means we can't rely on those hacks, however we have a bunch of tools with Argo anyway, so we just need to solve this problem (and not other problems such as the db version being dirty).

Describe the solution you'd like I'd like a simple way to allow golang-migrate to complete successfully if the version of the DB is newer than what we have.

I looked at the code, and this seems maybe like a lot more work, so a simpler option is just an option to disable checking if the current version exists. It is less obvious what this is for or why you would use it, but the code changes seem much simpler.

Describe alternatives you've considered Not really any others.

Additional context At least one other person in #556 suggested that they'd find this narrow piece useful.

SJrX commented 1 month ago

I put up a Proof of Concept of the changes that are the smallest and would unblock us.