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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
golang-migrate
does not provide a better way to handle these errors, it returns the error message as a string as seen herehttps://github.com/golang-migrate/migrate/blob/c378583d782e026f472dff657bfd088bf2510038/migrate.go#L809
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about
migrations.CheckLatestVersion
? Would this not accomplish something similar?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like @johnstcn's suggestion of checking the version first before trying to run the migrations over the string matching which could break. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mafredri @johnstcn I could do something like this. This check cannot precede
migrations.Up(sqlDB)
cause we want to run the migrations if the executable is the latest and the migrations have not yet been executed.wdyt?
PS: this would throw
Current database schema requires a newer version of Coder!
irrespective of error coming fromEnsureClean
or we should provide a custom error forCheckLatestVersion
insideEnsureClean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heads-up: we're making some parallel changes here #15980