fietsboek.updater package¶
Updating (data migration) logic for fietsboek.
- class fietsboek.updater.UpdateScript(source, name)¶
Bases:
objectRepresents an update script.
- property alembic_version: str¶
Returns the alembic revisions of the update.
- Returns:
The needed alembic revisions.
- downgrade(config, alembic_config)¶
Runs the downgrade migrations of this update script.
See also
upgrade().- Parameters:
config (
dict) – The app configuration.alembic_config (
Config) – The alembic config to use.
- property previous: list[str]¶
Returns all dependencies of the update.
- Returns:
The IDs of all dependencies of the update.
- upgrade(config, alembic_config)¶
Runs the upgrade migrations of this update script.
This first runs the pre_alembic task, then the alembic migration, and finally the post_alembic task.
Note that this does not ensure that all previous scripts have also been executed.
- Parameters:
config (
dict) – The app configuration.alembic_config (
Config) – The alembic config to use.
- class fietsboek.updater.UpdateState(*values)¶
Bases:
EnumState of the applied updates.
This represents a “summary” of the output that
fietsupdate statusproduces.- OKAY = 1¶
Everything is good, the data is up to date.
- OUTDATED = 2¶
The data is outdated, the update process should be run.
- TOO_NEW = 3¶
The data contains revisions that are not known to Fietsboek yet.
- UNKNOWN = 4¶
The data version could not be determined.
- class fietsboek.updater.Updater(config_path)¶
Bases:
objectA class that implements the updating logic.
This class is responsible for holding all of the update scripts and running them in the right order.
- current_versions()¶
Reads the current version of the data.
- downgrade(target)¶
Run the tasks to downgrade to the given target.
This ensures that all succeeding down-migrations are also run.
- Parameters:
target (
str) – The target revision.
- exists(revision_id)¶
Checks if the revision with the given ID exists.
- has_applied(revision_id, backward=False)¶
Checks whether the given revision is applied.
By default, this checks if a given update is applied, i.e. the current version is greater-or-equal to the given revision ID. If
backwardisTrue, we instead check if the current version is lower-or-equal to the given revision ID.Note that this function does not raise an error if the given revision ID cannot be found and instead simply returns
False. Useexists()to check whether the revision actually exists.
- heads()¶
Returns all “heads”, that are the latest revisions.
- load()¶
Load all update scripts into memory.
- new_revision(revision_id=None)¶
Creates a new revision with the current versions as dependencies and the current alembic version.
- stamp(versions)¶
Stampts the given version into the version file.
This does not run any updates, it simply updates the version information.
- Parameters:
version – The versions to stamp.
- state()¶
Checks the update state of the instance.
This returns a condensed version of what
fietsupdate statusoutputs.- Return type:
- Returns:
The update state of the data.