def METHOD_NAME(
    collected_migrations: List[Migration], executed_migrations: List[Migration], exception: Optional[Type[Exception]]
) -> None:
    assert DatabaseMigration.objects.distinct("version") == []
    plan = Plan(collected_migrations=collected_migrations)
    assert plan.executed_migrations == []
    if exception is None:
        # rollback worked
        plan.execute()
    else:
        # rollback failed
        with pytest.raises(exception):
            plan.execute()
    assert plan.executed_migrations == executed_migrations
    assert DatabaseMigration.objects.distinct("version") == [migration.version for migration in executed_migrations]