"""add rfp_profile_reference table

Revision ID: 3bd69f03a016
Revises: ddcfbfa665b5
Create Date: 2026-02-25 13:46:37.576946

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision: str = '3bd69f03a016'
down_revision: Union[str, Sequence[str], None] = 'ddcfbfa665b5'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('rfp_profile_reference',
    sa.Column('rfp_profile_id', sa.Integer(), nullable=False),
    sa.Column('reference_rfp_profile_id', sa.Integer(), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False),
    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.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
    sa.ForeignKeyConstraint(['reference_rfp_profile_id'], ['rfp_profile.id'], name=op.f('rfp_profile_reference_reference_rfp_profile_id_fkey'), ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['rfp_profile_id'], ['rfp_profile.id'], name=op.f('rfp_profile_reference_rfp_profile_id_fkey'), ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id', name=op.f('rfp_profile_reference_pkey')),
    sa.UniqueConstraint('rfp_profile_id', 'reference_rfp_profile_id', name='uq_rfp_profile_reference_pair')
    )
    op.create_index('ix_rfp_profile_ref_profile_id', 'rfp_profile_reference', ['rfp_profile_id'], unique=False)
    op.create_index('ix_rfp_profile_ref_reference_id', 'rfp_profile_reference', ['reference_rfp_profile_id'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('ix_rfp_profile_ref_reference_id', table_name='rfp_profile_reference')
    op.drop_index('ix_rfp_profile_ref_profile_id', table_name='rfp_profile_reference')
    op.drop_table('rfp_profile_reference')
    # ### end Alembic commands ###
