"""update_model_links

Revision ID: 6f28c32c3198
Revises: 5cb8b82b39fb
Create Date: 2025-07-09 17:49:05.126817

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '6f28c32c3198'
down_revision = '5cb8b82b39fb'
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('allergies', sa.Column('medication_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'allergies', 'medications', ['medication_id'], ['id'])
    op.add_column('encounters', sa.Column('condition_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'encounters', 'conditions', ['condition_id'], ['id'])
    op.add_column('medications', sa.Column('condition_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'medications', 'conditions', ['condition_id'], ['id'])
    op.add_column('procedures', sa.Column('condition_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'procedures', 'conditions', ['condition_id'], ['id'])
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'procedures', type_='foreignkey')
    op.drop_column('procedures', 'condition_id')
    op.drop_constraint(None, 'medications', type_='foreignkey')
    op.drop_column('medications', 'condition_id')
    op.drop_constraint(None, 'encounters', type_='foreignkey')
    op.drop_column('encounters', 'condition_id')
    op.drop_constraint(None, 'allergies', type_='foreignkey')
    op.drop_column('allergies', 'medication_id')
    # ### end Alembic commands ###
