Skip to content

Commit

Permalink
migrations: ignore unique constraint violation
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Dec 28, 2023
1 parent 5991c38 commit 3e65308
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions nexus/catalog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,31 @@ pub struct Catalog {
}

async fn run_migrations(client: &mut Client) -> anyhow::Result<()> {
let migration_report = embedded::migrations::runner()
let migration = embedded::migrations::runner()
.run_async(client)
.await
.context("Failed to run migrations")?;
for migration in migration_report.applied_migrations() {
tracing::info!(
"Migration Applied - Name: {}, Version: {}",
migration.name(),
migration.version()
);
.context("Failed to run migrations");
match migration {
Ok(migration_report) => {
for migration in migration_report.applied_migrations() {
tracing::info!(
"Migration Applied - Name: {}, Version: {}",
migration.name(),
migration.version()
);
}
Ok(())
}
Err(err) => {
let errstr = err.to_string();
if errstr.contains("duplicate key value violates unique constraint \"refinery_schema_history_pkey\"") ||
errstr.contains("(typname, typnamespace)=(refinery_schema_history, 2200) already exists") {
Ok(())
} else {
Err(err)
}
}
}
Ok(())
}

#[derive(Debug, Copy, Clone)]
Expand Down

0 comments on commit 3e65308

Please sign in to comment.