Skip to content

operation

Module for defining migration operations and operation types.

Operation

Bases: BaseModel

Represents a single operation in a migration.

Source code in src/cloe_delta_table_manager/migrations/operation.py
class Operation(BaseModel):
    """Represents a single operation in a migration."""

    model_config = ConfigDict(frozen=True)

    commands: list[str]
    operation_type: OperationType
    index: int

    def __str__(self) -> str:
        """Human-readable representation showing operation type and commands."""
        return f"[{self.index}] {self.operation_type.value}: {'; '.join(self.commands)}"

    def __hash__(self) -> int:
        """Make Operation hashable by converting list to tuple."""
        return hash((tuple(self.commands), self.operation_type, self.index))

__hash__()

Make Operation hashable by converting list to tuple.

Source code in src/cloe_delta_table_manager/migrations/operation.py
def __hash__(self) -> int:
    """Make Operation hashable by converting list to tuple."""
    return hash((tuple(self.commands), self.operation_type, self.index))

__str__()

Human-readable representation showing operation type and commands.

Source code in src/cloe_delta_table_manager/migrations/operation.py
def __str__(self) -> str:
    """Human-readable representation showing operation type and commands."""
    return f"[{self.index}] {self.operation_type.value}: {'; '.join(self.commands)}"

OperationType

Bases: StrEnum

Enum for operation types.

Source code in src/cloe_delta_table_manager/migrations/operation.py
class OperationType(StrEnum):
    """Enum for operation types."""

    CREATE = "create"
    DROP = "drop"
    ALTER = "alter"
    USER = "user"