'Loads dependency info for this migration, and stores it in itself
and any other relevant migrations.'

def calculate_dependencies(self):

    for migration in self._get_dependency_objects('depends_on'):
        self.dependencies.add(migration)
        migration.dependents.add(self)
    for migration in self._get_dependency_objects('needed_by'):
        self.dependents.add(migration)
        migration.dependencies.add(self)
    previous = self.previous()
    if previous:
        self.dependencies.add(previous)
        previous.dependents.add(self)
