"""Add table for configuration comparison

Revision ID: 655eefd69858
Revises: 1d0aaa07743c
Create Date: 2025-03-20 14:13:33.006662

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "655eefd69858"
down_revision: Union[str, None] = "1d0aaa07743c"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    ip_version_enum = sa.Enum("4", "6", name="ip_version_enum", create_type=False)
    method_enum = sa.Enum(
        "GET",
        "HEAD",
        "POST",
        "OPTIONS",
        "CONNECT",
        "TRACE",
        "PUT",
        "PATCH",
        "DELETE",
        name="method",
        create_type=False,
    )
    op.create_table(
        "tasks_tmp",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("url", sa.String(), nullable=False),
        sa.Column("domain", sa.String(), nullable=False),
        sa.Column("check", sa.String(), nullable=False),
        sa.Column("expected", sa.String(), nullable=False),
        sa.Column("frequency", sa.Float(), nullable=False),
        sa.Column("recheck_delay", sa.Float(), nullable=True),
        sa.Column("retry_before_notification", sa.Integer(), nullable=False),
        sa.Column("request_data", sa.String(), nullable=True),
        sa.PrimaryKeyConstraint("id"),
    )
    op.add_column("tasks_tmp", sa.Column("ip_version", ip_version_enum, nullable=False))
    op.add_column("tasks_tmp", sa.Column("method", method_enum, nullable=False))


def downgrade() -> None:
    op.drop_table("tasks_tmp")
