from dataclasses import dataclass

from dbt_common.exceptions import DbtRuntimeError


def compare_versions(v1: str, v2: str) -> int:
    v1_parts = v1.split('.')
    v2_parts = v2.split('.')
    for part1, part2 in zip(v1_parts, v2_parts):
        try:
            if int(part1) != int(part2):
                return 1 if int(part1) > int(part2) else -1
        except ValueError:
            raise DbtRuntimeError("Version must consist of only numbers separated by '.'")
    return 0
