New buckets for 0.6.0: migration code and build files

This commit is contained in:
Alex Auvolat
2021-12-16 13:17:09 +01:00
parent 0bbb6673e7
commit 4d30e62db4
11 changed files with 441 additions and 63 deletions
+27
View File
@@ -171,4 +171,31 @@ impl TableSchema for KeyTable {
}
}
}
fn try_migrate(bytes: &[u8]) -> Option<Self::E> {
let old_k =
match rmp_serde::decode::from_read_ref::<_, garage_model_050::key_table::Key>(bytes) {
Ok(x) => x,
Err(_) => return None,
};
let state = if old_k.deleted.get() {
crdt::Deletable::Deleted
} else {
// Authorized buckets is ignored here,
// migration is performed in specific migration code in
// garage/migrate.rs
crdt::Deletable::Present(KeyParams {
allow_create_bucket: crdt::Lww::new(false),
authorized_buckets: crdt::Map::new(),
local_aliases: crdt::LwwMap::new(),
})
};
let name = crdt::Lww::migrate_from_raw(old_k.name.timestamp(), old_k.name.get().clone());
Some(Key {
key_id: old_k.key_id,
secret_key: old_k.secret_key,
name,
state,
})
}
}