-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Add opt in automatic database migration #43
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
base: main
Are you sure you want to change the base?
Conversation
rustybee42
commented
Dec 10, 2025
- Rename --upgrade to --db-upgrade (keeping --upgrade as deprecated alias)
- Make it an enum, allowing true, false, auto; defaulting to true
- Add it to the config file (disallowing "true", which would prevent the management from starting)
a8504a6 to
44ab84b
Compare
44ab84b to
55aeedd
Compare
* Rename --upgrade to --db-upgrade (keeping --upgrade as deprecated alias) * Make it an enum, allowing true, false, auto; defaulting to true * Add it to the config file (disallowing "true", which would prevent the management from starting)
55aeedd to
640af3d
Compare
2419371 to
791d6e9
Compare
| # Decides how to upgrade the managements database schema, when required. | ||
| # Can be set to "auto" to perform an auto upgrade on startup without having to manually run with | ||
| # the --db-upgrade flag. Automatically creates a backup of the existing database file in the same | ||
| # directory. | ||
| # db-upgrade = "false" |
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.
suggestion(blocking): after thinking it over I think it would be more user friendly to just introduce a new boolean db-auto-upgrade parameter. That way we can just keep the --upgrade flag as it is today which avoids needing to update docs, training, etc.
| }) | ||
| .await?; | ||
|
|
||
| log::warn!("Database upgraded to version {version}"); |
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.
suggestion(non-blocking):
| log::warn!("Database upgraded to version {version}"); | |
| log::warn!("Database automatically upgraded to version {version}"); |
| if schema_check.is_err() { | ||
| upgrade_db(&db).await?; | ||
| } |
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.
suggestion(non-blocking): This would try to upgrade the DB on any error from the schema_check() including the outside the valid range error where this binary shouldn't try to migrate the on-disk DB.
The migration would never actually be attempted due to the second check in migrate_schema(), but it would try to take a backup then later fail. It would be better just to fail fast.
| Ok(()) | ||
| } | ||
|
|
||
| fn upgrade_db(db_file: &Path) -> Result<()> { |
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.
suggestion(non-blocking): it would be worth mentioning this only is used for the manual upgrade path and for automatic upgrades see the version in lib.rs.