diff --git a/crates/ascend/src/server/migrations.rs b/crates/ascend/src/server/migrations.rs index 7e92a16..fff90da 100644 --- a/crates/ascend/src/server/migrations.rs +++ b/crates/ascend/src/server/migrations.rs @@ -13,6 +13,43 @@ pub async fn run_migrations(db: &Database) -> Result<(), Box Result<(), Box> { + tracing::warn!("CANONICALIZING ALL PROBLEMS"); + + db.write(|txn| { + let mut walls_table = txn.open_table(db::v4::TABLE_WALLS)?; + + let walls_dump = walls_table + .iter()? + .map(|el| { + let (k, v) = el.unwrap(); + (k.value(), v.value()) + }) + .collect::>(); + + for (wall_uid, mut wall) in walls_dump.into_iter() { + wall.problems = wall + .problems + .into_iter() + .map(|mut problem| { + problem.pattern = problem.pattern.canonicalize(); + problem + }) + .collect(); + + walls_table.insert(wall_uid, wall)?; + } + + Ok(()) + }) + .await?; Ok(()) }