"""Migration file fix operations for converting timestamp to sequential versions.
This module provides utilities to convert timestamp-format migration files to
sequential format, supporting the hybrid versioning workflow where development
uses timestamps and production uses sequential numbers.
"""
import re
from dataclasses import dataclass
from pathlib import Path
from sqlspec.migrations._backup import create_backup, remove_backup, restore_backup
from sqlspec.utils.logging import get_logger
__all__ = ("MigrationFixer", "MigrationRename")
logger = get_logger(__name__)
@dataclass
class MigrationRename:
"""Represents a planned migration file rename operation.
Attributes:
old_path: Current file path.
new_path: Target file path after rename.
old_version: Current version string.
new_version: Target version string.
needs_content_update: Whether file content needs updating.
True for SQL files that contain query names.
"""
old_path: Path
new_path: Path
old_version: str
new_version: str
needs_content_update: bool