'Mark replacement migrations applied if their replaced set all are.
Do this unconditionally on every migrate, rather than just when
migrations are applied or unapplied, to correctly handle the case
when a new squash migration is pushed to a deployment that already had
all its replaced migrations applied. In this case no new migration will
be applied, but the applied state of the squashed migration must be
maintained.'

def check_replacements(self):

    applied = self.recorder.applied_migrations()
    for (key, migration) in self.loader.replacements.items():
        all_applied = all(((m in applied) for m in migration.replaces))
        if (all_applied and (key not in applied)):
            self.recorder.record_applied(*key)
