"""add parent_id to task unique constraint

Revision ID: cbad6afbe13d
Revises: 50bebf15de30
Create Date: 2024-06-13 23:59:45.211996

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "cbad6afbe13d"
down_revision: Union[str, None] = "50bebf15de30"
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.drop_constraint("uq_task_type_schedule", "task", type_="unique")
    op.create_unique_constraint(
        "uq_task_parent_id_type_schedule", "task", ["parent_id", "type", "schedule"]
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint("uq_task_parent_id_type_schedule", "task", type_="unique")
    op.create_unique_constraint("uq_task_type_schedule", "task", ["type", "schedule"])
    # ### end Alembic commands ###
