p2panda / aquadoggo

Node for the p2panda network handling validation, storage, aggregation and replication
GNU Affero General Public License v3.0
69 stars 5 forks source link

Node API to migrate lock files #598

Closed adzialocha closed 9 months ago

adzialocha commented 9 months ago

Introduces a migrate method on the Node struct to programmatically allow schema migrations and seeds.

let data = include_str!("schema.lock");
let lock_file: LockFile = toml::from_str(&data).expect("error parsing schema.lock file");
let node = Node::start(KeyPair::new(), Configuration::default()).await;
node.migrate(lock_file).await.expect("Migration failed");

This is maybe also a first step towards a general "low-level" API to interact with aquadoggo, for this we might want a NodeBuilder pattern instead to configure the node, while developers can use then the resulting Node itself to interact, but since this is a larger API change we should think this through a bit more.

Closes #597

📋 Checklist