fedimint_client::db

Function apply_migrations_client

Source
pub async fn apply_migrations_client(
    db: &Database,
    kind: String,
    migrations: BTreeMap<DatabaseVersion, ClientMigrationFn>,
    module_instance_id: ModuleInstanceId,
) -> Result<(), Error>
Expand description

apply_migrations_client iterates from the on disk database version for the client module up to target_db_version and executes all of the migrations that exist in the migrations map, including state machine migrations. Each migration in the migrations map updates the database to have the correct on-disk data structures that the code is expecting. The entire process is atomic, (i.e migration from 0->1 and 1->2 happen atomically). This function is called before the module is initialized and as long as the correct migrations are supplied in the migrations map, the module will be able to read and write from the database successfully.