def _get_previous_migration_number(migration_name: str) -> str:
    """
    Returns the previous migration number (0 padded number to 4 characters), or zero
    if the provided migration name is the first for a given app (usually 0001_initial).

    Examples:
          _get_previous_migration_number("0001_initial") -> "zero"
          _get_previous_migration_number("0009_migration_9") -> "0008"
          _get_previous_migration_number("0103_migration_103") -> "0102"
    """

    migration_number = int(migration_name.split("_", maxsplit=1)[0])
    return f"{migration_number - 1:04}" if migration_number > 1 else "zero"

    Returns the previous migration number (0 padded number to 4 characters), or zero
    if the provided migration name is the first for a given app (usually 0001_initial).

    Examples:
          _get_previous_migration_number("0001_initial") -> "zero"
          _get_previous_migration_number("0009_migration_9") -> "0008"
          _get_previous_migration_number("0103_migration_103") -> "0102"
    
api/core/management/commands/rollbackmigrationsappliedafter.py