"""add_uniqueness_constraints_on_exchange

Revision ID: 258ee56e7873
Revises: e726c627ded5
Create Date: 2024-11-23 11:38:06.827226

"""

from typing import Sequence
from typing import Union

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = "258ee56e7873"
down_revision: Union[str, None] = "e726c627ded5"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(
        "xarizmi_candlestick",
        "interval_type",
        existing_type=postgresql.INTERVAL(),
        type_=sa.Enum(
            "MIN_1",
            "MIN_3",
            "MIN_5",
            "MIN_15",
            "MIN_30",
            "HOUR_1",
            "HOUR_2",
            "HOUR_4",
            "HOUR_6",
            "HOUR_8",
            "HOUR_12",
            "DAY_1",
            "DAY_7",
            "DAY_14",
            "WEEK_1",
            "MONTH_1",
            name="interval_type_enum",
        ),
        existing_nullable=False,
    )
    op.create_unique_constraint(None, "xarizmi_exchange", ["name"])
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, "xarizmi_exchange", type_="unique")  # noqa: E501
    op.alter_column(
        "xarizmi_candlestick",
        "interval_type",
        existing_type=sa.Enum(
            "MIN_1",
            "MIN_3",
            "MIN_5",
            "MIN_15",
            "MIN_30",
            "HOUR_1",
            "HOUR_2",
            "HOUR_4",
            "HOUR_6",
            "HOUR_8",
            "HOUR_12",
            "DAY_1",
            "DAY_7",
            "DAY_14",
            "WEEK_1",
            "MONTH_1",
            name="interval_type_enum",
        ),
        type_=postgresql.INTERVAL(),
        existing_nullable=False,
    )
    # ### end Alembic commands ###
