"""Added RFP profle

Revision ID: b093fb58df2c
Revises: f7400dfdcdc5
Create Date: 2026-02-18 14:27:32.690642

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'b093fb58df2c'
down_revision: Union[str, Sequence[str], None] = 'f7400dfdcdc5'
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',
    sa.Column('enterprise_name', sa.String(length=255), nullable=True),
    sa.Column('organization_size', sa.Integer(), nullable=True),
    sa.Column('mobile_app_required', sa.Boolean(), nullable=True),
    sa.Column('coverage_type', sa.String(length=100), nullable=True),
    sa.Column('questionnaire_data', sa.JSON(), nullable=True),
    sa.Column('additional_data', sa.JSON(), nullable=True),
    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.PrimaryKeyConstraint('id', name=op.f('rfp_profile_pkey'))
    )
    op.create_index(op.f('rfp_profile_enterprise_name_idx'), 'rfp_profile', ['enterprise_name'], unique=False)
    op.add_column('rfp', sa.Column('rfp_profile_id', sa.Integer(), nullable=True))
    op.add_column('rfp', sa.Column('document_id', sa.Integer(), nullable=True))
    op.create_unique_constraint(op.f('rfp_document_id_key'), 'rfp', ['document_id'])
    op.create_index(op.f('rfp_rfp_profile_id_idx'), 'rfp', ['rfp_profile_id'], unique=False)
    op.create_foreign_key(op.f('rfp_rfp_profile_id_fkey'), 'rfp', 'rfp_profile', ['rfp_profile_id'], ['id'], ondelete='SET NULL')
    op.create_foreign_key(op.f('rfp_document_id_fkey'), 'rfp', 'document', ['document_id'], ['id'], ondelete='SET NULL')
    op.drop_column('rfp', 'enterprise_name')
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('rfp', sa.Column('enterprise_name', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.drop_constraint(op.f('rfp_document_id_fkey'), 'rfp', type_='foreignkey')
    op.drop_constraint(op.f('rfp_rfp_profile_id_fkey'), 'rfp', type_='foreignkey')
    op.drop_index(op.f('rfp_rfp_profile_id_idx'), table_name='rfp')
    op.drop_constraint(op.f('rfp_document_id_key'), 'rfp', type_='unique')
    op.drop_column('rfp', 'document_id')
    op.drop_column('rfp', 'rfp_profile_id')
    op.drop_index(op.f('rfp_profile_enterprise_name_idx'), table_name='rfp_profile')
    op.drop_table('rfp_profile')
    # ### end Alembic commands ###
