def select_migrations(current, target, migration_ids):
    """
    Select direction and migrations to run,
    given current and target migrations,
    from a list of migration ids
    """
    if target > current:
        return 'forward', [
            id_ for id_ in migration_ids
            if current < id_ <= target
        ]
    if target < current:
        return 'reverse', [
            id_ for id_ in reversed(migration_ids)
            if target < id_ <= current
        ]
    return None, []