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

Add a function to rollback to a target migration similar to migrate-until-just-before for ups #200

Open
vincentjames501 opened this issue Feb 17, 2021 · 3 comments

Comments

@vincentjames501
Copy link
Contributor

Right now you can only down migrations by a specific id(s). Sometimes, I want to rollback to a specific point similar to going up to a specific point via migratus.core/migrate-until-just-before. Could the implementation be as simple as:

(defn rollback-until-just-after
  [config migration-id]
  (with-store [store (proto/make-store config)]
              (->> (uncompleted-migrations config store)
                   (map proto/id)
                   distinct
                   sort
                   reverse
                   (take-while #(> % migration-id))
                   (apply down config))))

Does this make sense?

@yogthos
Copy link
Owner

yogthos commented Feb 17, 2021

Yeah, I think that would be reasonable. If you want to make a PR with the feature and maybe add a test, I'll push out a release.

vincentjames501 pushed a commit to vincentjames501/migratus that referenced this issue Feb 17, 2021
@vincentjames501
Copy link
Contributor Author

PR sent w/ test added.

yogthos pushed a commit that referenced this issue Feb 17, 2021
Co-authored-by: Vincent Pizzo <vincent.pizzo@singlewire.com>
@yogthos
Copy link
Owner

yogthos commented Feb 17, 2021

Fantastic, just pushed 1.3.5 to Clojars with the new functionality. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants