-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
feat: allow Go migrations outside of an SQL transaction #696
Conversation
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.
LGTM, with one small idea on how to improve the test :)
if _, err := c.Store.Exec("INSERT INTO tests (i, j) VALUES (?, ?)", i1, j1); err != nil { | ||
return errors.WithStack(err) | ||
} | ||
close(up1) |
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.
This took me a while to understand. You are passing control back here to see if the changes take effect immediately, right? Could you not just execute a closure instead which connection is bound to the top-level c
?
Define in the top level:
assertValues := func(i int) {
var j int64
require.NoError(t, c.Store.Get(&j, "SELECT j FROM tests WHERE i = ?", i))
assert.Equal(t, j1, j)
And then call it as part of the migrations.
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.
From my side it's ok to merge as is
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.
Yeah, the closure would work too. Would be a little bit neater perhaps.
This works, so 🤷
No description provided.