Skip to content
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

Allow for user-provided schema version storage and retrivial #3588

Open
Shirogaki opened this issue Nov 1, 2024 · 1 comment
Open

Allow for user-provided schema version storage and retrivial #3588

Shirogaki opened this issue Nov 1, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Shirogaki
Copy link

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.

@Shirogaki Shirogaki added the enhancement New feature or request label Nov 1, 2024
@abonander
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants