atomica.migration.register_migration

atomica.migration.register_migration(registry, classname, original_version, new_version, description, date=None, update_required=False)[source]

Decorator to register migration functions

This decorator constructs a Migration object from a decorated migration function, and registers it in the module’s list of migrations to be run when calling migrate()

Parameters
  • registry – Dictionary storing {classname:[migrations]}

  • original_version – Version string for the start version. Function will only run on projects whose version is <= this

  • new_version – The resulting project is assigned this version

  • description – A brief overview of the purpose of this migration

  • date – Optionally specify the date when this migration was written

  • update_required – Optionally flag that changes to model output may occur - the flag is stored in the object’s _update_required attribute. Objects can optionally contain this attribute, so it’s not necessary if the object is planned not to require such a flag.

Returns

None

Example usage:

@migration('Project','1.0.0', '1.0.1', 'Upgrade project', update_required=True)
def _update_project(proj):
    ...
    return proj

The migration function (update_project()) takes a single argument which is a project object, and returns a project object. Decorating the function registers the migration and it will automatically be used by migrate() and therefore Project.load()