Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(storage): allow profile v1 database as import target during migration

Steven Enamakelc1102a371385
diff --git a/crates/openhuman-core/src/storage/scope_move_boot.rs b/crates/openhuman-core/src/storage/scope_move_boot.rs
index dd39b1e9a3..2731f77657 100644
--- a/crates/openhuman-core/src/storage/scope_move_boot.rs
+++ b/crates/openhuman-core/src/storage/scope_move_boot.rs
@@ -142,7 +142,7 @@ fn import_inventory(
}
};
let (scope_backend, profile_guard) =
- backend_for_target_scope(backend, &target_scope, known, config)?;
+ backend_for_target_scope(backend, &target_scope, known, config, source_path)?;
let marker = crate::storage::documents::Repo::on(
&scope_backend,
&target_scope,
@@ -276,6 +276,7 @@ fn backend_for_target_scope(
target_scope: &Scope,
known: &Known,
config: &crate::config::Config,
+ source_path: &Path,
) -> anyhow::Result<BackendForScope> {
let parsed = target_scope.parsed()?;
if matches!(parsed.tenant, crate::storage::Tenant::Local | crate::storage::Tenant::Cluster) {
@@ -299,6 +300,19 @@ fn backend_for_target_scope(
target_scope.as_str()
)
})?;
+ // During the profile layout migration, the importer is deliberately
+ // running against that profile's v1 database. Its own u:<profile> rows
+ // must be copied within this source before the database is checkpointed
+ // and moved to the v2 location. The profile migration lock is held by the
+ // caller, so this explicit source backend is the admitted destination for
+ // this one transition.
+ if let Some(target) = crate::storage::layout::Target::from_config(config) {
+ if target.user_id == *original_id
+ && source_path == crate::storage::layout::legacy::v1_db(&target)
+ {
+ return Ok((Arc::clone(backend), None));
+ }
+ }
let Some(host) = crate::profiles::host::host() else {
if let Some(target) = crate::storage::layout::Target::from_config(config) {
let expected_url = format!("sqlite:{}", target.storage_db().display());