versioning package

Submodules

update_registry module

versioning.update_registry.update_registry = {'Map': {0: None}, 'Settings': {0: None}, 'UserProfile': {0: <function migrate_v0_to_v1>, 1: <function migrate_v1_to_v2>}}

Registry mapping data types to their migration functions by version.

The structure is:

{
    "DataType": {
        version_number: migration_function_or_None,
        ...
    },
    ...
}

Each migration function should accept the old data format and return the new format.

updater module

class versioning.updater.Updater(registry)

Bases: object

Module for handling versioned data migrations using a registry of migration functions.

This class applies sequential migrations to data entities based on their type and version.

update(entity_type, data, current_version)

Update the given data entity to the latest version using registered migrations.

Parameters:
  • entity_type (str) – The type of the entity to update.

  • data (dict) – The data to be migrated.

  • current_version (int) – The current version of the data.

Returns:

The migrated data at the latest version.

Return type:

dict

Raises:
  • ValueError – If there are no migrations registered for the given entity type.

  • TypeError – If a migration function does not return a dictionary.