pub async fn apply_migrations(
db: &Database,
kind: String,
migrations: BTreeMap<DatabaseVersion, CoreMigrationFn>,
module_instance_id: Option<ModuleInstanceId>,
external_prefixes_above: Option<u8>,
) -> Result<(), Error>
Expand description
apply_migrations
iterates from the on disk database version for the
module.
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 migrations map. Each migration in migrations map 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 the migrations map,
the module will be able to read and write from the database successfully.