"""add_workstream_dependencies

Revision ID: 0b547c153153
Revises: 0001
Create Date: 2026-02-25 17:26:54.017622

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '0b547c153153'
down_revision: Union[str, None] = '0001'
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.create_table('workstream_dependencies',
    sa.Column('id', sa.UUID(), nullable=False),
    sa.Column('from_workstream_id', sa.UUID(), nullable=False),
    sa.Column('to_workstream_id', sa.UUID(), nullable=False),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
    sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
    sa.ForeignKeyConstraint(['from_workstream_id'], ['workstreams.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['to_workstream_id'], ['workstreams.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('from_workstream_id', 'to_workstream_id', name='uq_ws_dep_pair')
    )
    op.create_index(op.f('ix_workstream_dependencies_from_workstream_id'), 'workstream_dependencies', ['from_workstream_id'], unique=False)
    op.create_index(op.f('ix_workstream_dependencies_to_workstream_id'), 'workstream_dependencies', ['to_workstream_id'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_workstream_dependencies_to_workstream_id'), table_name='workstream_dependencies')
    op.drop_index(op.f('ix_workstream_dependencies_from_workstream_id'), table_name='workstream_dependencies')
    op.drop_table('workstream_dependencies')
    # ### end Alembic commands ###
