-
Notifications
You must be signed in to change notification settings - Fork 516
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 -dry-run flag #479
base: master
Are you sure you want to change the base?
add -dry-run flag #479
Conversation
Hey @mfridman! Thanks so much for all your work keeping this repository maintained. I know you're in the middle of several other refactors and sorry to bother, but just wanted to see if you might be willing to take a look at this at some point. Thanks in advance! |
Thanks for contributing a PR, I'll take a closer look by the end of the week. I presume the |
That's exactly it, yes! |
Hey @mfridman, just wanted to bump this once more if you're willing to review. Thanks so much! |
Sorry @elijahcarrel, I've been holding off on reviewing this PR because I'm a bit hesitant about adding more functionality to the My challenge is finding the right balance of adding new features in a way that makes sense with the existing goose API. This project is 10+ yo with many folks contributing, and new Go best practices have evolved over time, and it has been a bit challenging adding new features while compromising ergonomics. The functional options were a means to an end, but I'm not sure how sustainable it is. Most of my efforts have been concentrated on the Having said that, I'll try to find some time to revisit this issue. But at least wanted to give you an update on the delay. |
Makes total sense, thanks so much for your consideration! I'm open to holding off until v4 as it's not urgent (as long as the timeline for v4 isn't years out). As additional context, the motivation for me is that my company made our own fork years ago (https://github.com/grailbio-external/goose), made several changes, and ceased to keep it up to date with this one, and it's now woefully out of sync . |
Gotcha, thanks for that explanation. This makes total sense, and it's always appreciated when folks take the time to contribute back upstream. I need a bit of time to think this through, but I think this is reasonable. Given this touches quite a bit of the internals I'll spend some time reviewing it carefully. Bonus, this also partially addresses something I've been thinking about previously. |
Hi,
Then store the results of these commands in a json and generate a hash for the json and save it inside the migrations folder as a state file (like terraform does). When run the --dry-run command comapre the saved hash with the DB hash and return the results. @mfridman @elijahcarrel what are you thinking? if there is any thing to change or incorrect please let me know. :) (This flow is for the postgresql) |
Adds a
-dry-run
flag which can be used onup
,up-to
,up-by-one
,down
, anddown-to
commands which performs all of the same print statements and error checking, aside from the ones performed as part of actually executing the up or down migrations respectively.This adds the following utility:
This change is fully backwards-compatible both for go clients as well as command-line clients, as it simply adds a new command-line flag and adds a new go option which defaults to false (as one would expect).
To validate this change, nearly the entire e2e test suite was replicated into a new file
dry_run_test.go
and tests were modified to perform appropriate dry runs before performing the command for real. In each case, the test validates that the dry run produced the same errors (or lack of errors) as the non-dry run command, but that it does not have any effect on the database. If the maintainers so desire, I could instead port these test cases back into the existing test suite (which would have the benefit of less copied test code, but the downside of making each test longer and more complex).Fixes #281