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.
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.
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.
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.
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.