Function fedimint_core::db::apply_migrations
source · pub async fn apply_migrations(
db: &Database,
kind: String,
target_db_version: DatabaseVersion,
migrations: MigrationMap
) -> Result<(), Error>
Expand description
apply_migrations
iterates from the on disk database version for the module
up to target_db_version
and executes all of the migrations that exist in
the MigrationMap
. Each migration in MigrationMap
updates the database to
have the correct on-disk structures that the code is expecting. The entire
migration 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 MigrationMap
, the module
will be able to read and write from the database successfully.