Skip to content

Commit

Permalink
Merge pull request #4181 from systeminit/import-schema-past-hashes-up…
Browse files Browse the repository at this point in the history
…date

fix(dal): Ensure that we search the past_hashes when installing a schema
  • Loading branch information
stack72 authored Jul 19, 2024
2 parents 10c8244 + 2d7c94b commit 79b9a19
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/dal/src/pkg/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ async fn import_change_set(
installed_module.clone(),
thing_map,
options.create_unlocked,
options.past_module_hashes.clone(),
)
.await?;

Expand Down Expand Up @@ -449,19 +450,24 @@ async fn import_schema(
installed_module: Option<Module>,
thing_map: &mut ThingMap,
create_unlocked: bool,
past_hashes: Option<Vec<String>>,
) -> PkgResult<(Option<SchemaId>, Vec<SchemaVariantId>)> {
let schema_and_category = {
let mut existing_schema: Option<Schema> = None;
let mut existing_schema_id = None;

if let Some(installed_module) = installed_module.as_ref() {
existing_schema_id = installed_module.schema_id();
if let Some(matching_module) = installed_module.find_matching_module(ctx).await? {
existing_schema = matching_module
.list_associated_schemas(ctx)
.await?
.into_iter()
.next();
// loop through past hashes to find matching schema
if let Some(maybe_past_hashes) = past_hashes {
for past_hash in maybe_past_hashes {
// find if there's an existing module
// if there is, find the asssociated schemas
if let Some(found) = Module::find_by_root_hash(ctx, past_hash).await? {
existing_schema =
found.list_associated_schemas(ctx).await?.into_iter().next();
}
}
}
}

Expand Down

0 comments on commit 79b9a19

Please sign in to comment.