Migration class

Class definition

class dynamodb_mapper.migration.Migration(model)

Migration engine base class. It defines all the magic to make things easy to use. To migrate a raw schema, only instanciate the migrator and “call” the instance with the raw_dict.

>>> migrator = DataMigration()
>>> migrated_raw_data = migrator(raw_data)

Migrators must derive from this class and implement methods of the form - check_N(raw_data) -> returns True if raw_data is compatible with version N - migrate_to_N(raw_data) -> migrate from previous version to this one

check_N are all called in the decreasing order. The first to return True determines the version.

All migrators functions are called successively starting at N+1 assuming N is the current version number

N version numbers do not need to be consecutive and are sorted in natural order.



Gather all the version detectors and migrators on the first call. They are then cached for all further instances.

Parameters:model – model class this migrator handles



Trigger the the 2 steps migration engine:

  1. detect the current version
  2. migrate to all newest versions
Parameters:raw_data – Raw boto dict to migrate to latest version
Returns:Up to date raw boto dict
Raises VersionError:
 when no check succeeded

Project Versions

Table Of Contents

Previous topic

Connection class

Next topic

Model class

This Page