"""adjust_family_share_constraint

Revision ID: 14cd756b39ad
Revises: 7c71e5dae903
Create Date: 2025-07-23 16:48:16.148809

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '14cd756b39ad'
down_revision = '7c71e5dae903'
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('activity_logs_patient_id_fkey', 'activity_logs', type_='foreignkey')
    op.create_foreign_key(None, 'activity_logs', 'patients', ['patient_id'], ['id'])
    op.drop_constraint('unique_family_history_share', 'family_history_shares', type_='unique')
    op.create_unique_constraint('unique_active_family_history_share', 'family_history_shares', ['family_member_id', 'shared_with_user_id', 'is_active'])
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('unique_active_family_history_share', 'family_history_shares', type_='unique')
    op.create_unique_constraint('unique_family_history_share', 'family_history_shares', ['family_member_id', 'shared_with_user_id'])
    op.drop_constraint(None, 'activity_logs', type_='foreignkey')
    op.create_foreign_key('activity_logs_patient_id_fkey', 'activity_logs', 'patients', ['patient_id'], ['id'], ondelete='CASCADE')
    # ### end Alembic commands ###
