"""channel aliases across department sections Revision ID: 0011 Revises: 0010 Create Date: 2026-06-08 """ from typing import Sequence, Union import sqlalchemy as sa from alembic import op revision: str = "0011" down_revision: Union[str, None] = "0010" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: op.add_column("channels", sa.Column("source_channel_id", sa.Integer(), nullable=True)) op.create_foreign_key( "fk_channels_source_channel_id", "channels", "channels", ["source_channel_id"], ["id"], ondelete="SET NULL", ) op.drop_constraint("channels_identifier_key", "channels", type_="unique") op.create_unique_constraint( "uq_channels_section_identifier", "channels", ["section_id", "identifier"], ) op.create_index("ix_channels_source_channel_id", "channels", ["source_channel_id"]) def downgrade() -> None: op.drop_index("ix_channels_source_channel_id", table_name="channels") op.drop_constraint("uq_channels_section_identifier", "channels", type_="unique") op.create_unique_constraint("channels_identifier_key", "channels", ["identifier"]) op.drop_constraint("fk_channels_source_channel_id", "channels", type_="foreignkey") op.drop_column("channels", "source_channel_id")