INNER CODE UNIT · Rust
ensure_schema
aannoo/hcom · src/db/mod.rs:475
pub fn ensure_schema(&mut self) -> Result<()> {
match self.check_schema_compat()? {
SchemaCompat::Ok => {
self.init_db()?;
Ok(())
}
SchemaCompat::NeedsArchive(reason, old_version) => {
if let Some(version) = old_version {
// A DB can be stamped at some version yet be missing columns
// an earlier migration should have added ("stamped without
// migration"). The stamp alone can't tell us how far back to
// start, so key off the columns actually present.
let migrate_from = self.repair_migrate_from(version);
match self.try_apply_migrations(migrate_from) {
Ok(true) => return Ok(()),
Ok(false) => {}
Err(e) => {
crate::log::log_warn(