Rename CheckPending to GetVersions #764
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Picking up from #762 (comment)
I don't want to give the impression this method is suitable for checking "pending" migrations because it's a bit nuanced. I.e., what if a missing (out-of-order) migration has snuck in, it'd be silently ignored if we just compare the max db version and target filesystem version.
This is what
HasPending
is intended to do, handle all the edge cases around missing migrations (which can be enabled or disabled). For a better understanding of all the possible cases see:https://github.com/pressly/goose/blob/8c8def43/provider.go#L530-L544 and https://github.com/pressly/goose/blob/8c8def43/internal/gooseutil/resolve_test.go#L73-L83
Once you enumerate the edge cases it becomes clear that internally we cannot compare latest versions, e.g., what happens when running
goose up-to 4
and the current db version is 6, where the "missing" migration is 5? I'll write up a reference for "What is a missing migration?"TL;DR
So, rename
CheckPending
toGetVersions
which does what it says on the tin: get the (max) version from the database and filesystem, which are termed current and target, respectively.