"""add_drug_label_table

Revision ID: 78df8a158978
Revises: 68fbca1b0457
Create Date: 2026-07-16 06:52:18.039959
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

revision: str = '78df8a158978'
down_revision: Union[str, None] = '68fbca1b0457'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.create_table('drug_labels',
    sa.Column('id', sa.Uuid(), nullable=False),
    sa.Column('application_number', sa.String(length=20), nullable=True),
    sa.Column('drug_name', sa.String(length=500), nullable=False),
    sa.Column('generic_name', sa.String(length=500), nullable=False),
    sa.Column('set_id', sa.String(length=100), nullable=False),
    sa.Column('effective_time', sa.String(length=20), nullable=True),
    sa.Column('indications_and_usage', sa.Text(), nullable=True),
    sa.Column('mechanism_of_action', sa.Text(), nullable=True),
    sa.Column('clinical_studies', sa.Text(), nullable=True),
    sa.Column('warnings', sa.Text(), nullable=True),
    sa.Column('adverse_reactions', sa.Text(), nullable=True),
    sa.Column('nct_numbers', sa.JSON(), 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.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('set_id')
    )
    op.create_index(op.f('ix_drug_labels_application_number'), 'drug_labels', ['application_number'], unique=False)


def downgrade() -> None:
    op.drop_index(op.f('ix_drug_labels_application_number'), table_name='drug_labels')
    op.drop_table('drug_labels')
