Skip to content

Commit

Permalink
Fix migration logging output (#1052)
Browse files Browse the repository at this point in the history
Before, when the DB was up to date, it was printed: "db up to date"
followed by "executed 1 migration, up to date now". That's fixed now.
  • Loading branch information
owi92 authored Jan 9, 2024
2 parents fbf4dcb + 201d40b commit a39ab02
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions backend/src/db/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,7 @@ impl MigrationPlan {
/// `done`, i.e. `true` if the DB is up to date after this method call.
pub(crate) async fn execute_next(&self, tx: &Transaction<'_>) -> Result<bool> {
let id = match self {
Self::UpToDate => {
info!("All migrations are already applied: database schema is up to date.");
return Ok(true);
}
Self::UpToDate => return Ok(true),
Self::EmptyDb => {
create_meta_table_if_missing(tx).await?;
0
Expand Down Expand Up @@ -231,6 +228,10 @@ pub async fn migrate(db: &mut Client) -> Result<()> {
// script runs in its own transaction. Otherwise certain things
// (like adding a value to an enum) don't work.
let plan = MigrationPlan::build(&tx).await?;
if matches!(plan, MigrationPlan::UpToDate) && migrations_executed == 0 {
info!("All migrations are already applied: database schema is up to date.");
return Ok(());
}
let is_done = plan.execute_next(&tx).await?;


Expand Down

0 comments on commit a39ab02

Please sign in to comment.