"""Allow tasks to add or overwrite alerts recipients

Revision ID: f0b3ce75afa4
Revises: 655eefd69858
Create Date: 2025-05-21 16:41:58.193914

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


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


def upgrade() -> None:
    with op.batch_alter_table("tasks", schema=None) as batch_op:
        batch_op.add_column(
            sa.Column("add_alerts_recipients", sa.String(), nullable=True)
        )
        batch_op.add_column(
            sa.Column("overwrite_alerts_recipients", sa.String(), nullable=True)
        )

    with op.batch_alter_table("tasks_tmp", schema=None) as batch_op:
        batch_op.add_column(
            sa.Column("add_alerts_recipients", sa.String(), nullable=True)
        )
        batch_op.add_column(
            sa.Column("overwrite_alerts_recipients", sa.String(), nullable=True)
        )


def downgrade() -> None:
    with op.batch_alter_table("tasks_tmp", schema=None) as batch_op:
        batch_op.drop_column("overwrite_alerts_recipients")
        batch_op.drop_column("add_alerts_recipients")

    with op.batch_alter_table("tasks", schema=None) as batch_op:
        batch_op.drop_column("overwrite_alerts_recipients")
        batch_op.drop_column("add_alerts_recipients")
