atomica.migration

atomica.migration(original_version, new_version, description, date=None, changes_results=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:
  • 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
  • changes_results – Optionally flag that changes to model output may occur
Returns:

None

Example usage:

@migration('1.0.0', '1.0.1', 'Upgrade project', changes_results=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()