-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Today, the way SQL database migrations work with golang-migrate/migrate
is that we only have a single "track" of migrations, meaning a single folder with migration files that need to be numbered in a strictly incremental way.
But because we'll have optional migrations in the future (either toggled through a CLI flag such as the --db.use-native-sql
flag or through build tags to toggle not-yet-finished features in unit or integration tests), keeping things in strict order might become tricky.
Especially if there are multiple, distinct sub-projects working on migrating databases over to SQL (the existing invoice DB and the upcoming payments and graph databases), there are bound to be conflicts.
Also having those three (and in the future even more) distinct functionality sub-projects create files will lead to a hard-to-understand sequence of files.
We can start using different tracks if we change the following:
- Specify a distinct
MigrationsTable
for each track inpgx_migrate.Config{}
. The default would beschema_migrations
which we would use for existing migrations (e.g. the native invoice migrations). Any new "track" would get a different name, for example:schema_migrations_payments
orschema_migrations_graph
. See - Store the files for each track in a different folder and specify that here:
Line 182 in 7e54682
postgresFS, driver, "sqlc/migrations", dbName, target,
As a side task it would make sense to move any of the actual migration lists or feature specific functionality out of the sqldb
package so it only contains generic code that can be re-used in our other projects.