-
-
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
chore(popx): code simplification and refactoring #816
Conversation
if len(legacyVersion) > 14 { | ||
legacyVersion = legacyVersion[:14] | ||
} | ||
err := c.RawQuery(fmt.Sprintf("SELECT version FROM %s WHERE version IN (?, ?)", mtn), mi.Version, legacyVersion).All(&appliedMigrations) |
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.
We've now combined two queries into one, which should half the number of queries and (depending on the database) can significantly improve the performance of the migrate job.
if m.Connection.Dialect.Name() == "cockroach" { | ||
outer := fn | ||
fn = func() error { | ||
return crdb.Execute(outer) |
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 the documentation of crdb.Execute
:
It is used to add retry handling to the execution of a single statement. If a multi-statement transaction is being run, use ExecuteTx instead.
But as the transaction is started within, we don't need to retry anything at this point.
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.
With my recent auto-commit changes, we should add retry to migrations that run without transactions (aka go migrations and auto commit transactions).
) | ||
|
||
//go:embed stub/migrations/transactional/*.sql | ||
var transactionalMigrations embed.FS | ||
|
||
func TestMigratorUpgrading(t *testing.T) { |
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 test was mostly skipped anyway, and I removed the "legacy" migrator with this PR, so no need to test compatibility anymore.
a10280b
to
13b5cd0
Compare
While debugging the migrator, I stumbled upon a couple of improvements that could be made.
I also removed the pkgerx package, as we don't use that now for years.