Schema migrations

The generic schema-migration framework.

ModelManager.continueMilestoneUpgradeMethod
continueMilestoneUpgrade(version::VersionNumber, auto_upgrade::Bool)

Print a warning about the schema change at version and prompt the user to confirm unless auto_upgrade is true. Returns true if the upgrade should proceed, false if the user aborted.

Call this at the top of any upgradeToMilestone implementation that makes large or destructive changes to the database schema.

source
ModelManager.populateTableOnFeatureSubsetMethod
populateTableOnFeatureSubset(db::SQLite.DB, source_table::String, target_table::String; column_mapping::Dict{String,String}=Dict{String,String}())

Populate a target_table with rows from source_table. Columns in source_table that exist (possibly under a different name) in target_table are copied; extras are ignored. Use column_mapping to rename columns during the copy (source_name => target_name).

source
ModelManager.upgradePackageMethod
upgradePackage(sim::AbstractSimulator, db::SQLite.DB, from_version::VersionNumber, to_version::VersionNumber, auto_upgrade::Bool)

Drive the database migration from from_version to to_version for the simulator framework sim.

For each milestone v in upgradeMilestones(sim) with from_version < v ≤ to_version, calls upgradeToMilestone(sim, v, auto_upgrade). After a successful milestone upgrade the version table is updated immediately so that a partial upgrade is recoverable. If any milestone fails the chain is aborted and false is returned.

After all milestones pass, if to_version is beyond the last milestone the version table is stamped with to_version (a "no schema change" bump).

A to_version beyond the version loaded in this session is refused, leaving the version table untouched.

source