Reading the documentation, the migration table is hardcoded to _sqlx_migrations with an implementation defined schema.
Since I'm already going to have a small table for unique key-value pairs, I'd like to store the version schema in that table. If possible, I think an interface like this would be ideal:
let current_schema_version: i64; // User code to fetch the current version.
let new_schema_version = migrate_from!(current_version).await?;
// User code that saves the new version somewhere.
Otherwise if reusing the Migrator struct is preferable:
let current_schema_version: i64; // User code to fetch the current version.
let new_schema_version = migrate!()
.with_current(current_version)
.run(&pool)
.await?;
// User code that saves the new version somewhere.
Describe alternatives you've considered
Right now the Migrator object seem to offer a way for the user to define their own migration source with the MigrationSource trait, but it doesn't seem to offer an API to load and retrieve the current version.
If you want to get the current applied version, you can call Migrate::list_applied_migrations() on a connection and look at the last migration in the list.
Reading the documentation, the migration table is hardcoded to
_sqlx_migrations
with an implementation defined schema.Since I'm already going to have a small table for unique key-value pairs, I'd like to store the version schema in that table. If possible, I think an interface like this would be ideal:
Otherwise if reusing the Migrator struct is preferable:
Describe alternatives you've considered Right now the Migrator object seem to offer a way for the user to define their own migration source with the MigrationSource trait, but it doesn't seem to offer an API to load and retrieve the current version.