fix: clinic doc delete

This commit is contained in:
deepvasoya 2025-05-26 18:40:59 +05:30
parent 36c439ba0e
commit 611de1bf2a
2 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,38 @@
"""relation update
Revision ID: a19fede0cdc6
Revises: 48785e34c37c
Create Date: 2025-05-26 18:37:53.781411
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'a19fede0cdc6'
down_revision: Union[str, None] = '48785e34c37c'
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.drop_constraint('appointment_relations_clinic_doctor_id_fkey', 'appointment_relations', type_='foreignkey')
op.create_foreign_key(None, 'appointment_relations', 'clinic_doctors', ['clinic_doctor_id'], ['id'], ondelete='CASCADE')
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('users', 'clinicRole',
existing_type=sa.Enum('DIRECTOR', 'PRACTICE_MANAGER', name='clinicuserroles'),
type_=sa.VARCHAR(),
existing_nullable=True)
op.drop_constraint(None, 'appointment_relations', type_='foreignkey')
op.create_foreign_key('appointment_relations_clinic_doctor_id_fkey', 'appointment_relations', 'clinic_doctors', ['clinic_doctor_id'], ['id'])
# ### end Alembic commands ###

View File

@ -8,7 +8,7 @@ class AppointmentRelations(Base, CustomBase):
id = Column(Integer, primary_key=True, index=True) id = Column(Integer, primary_key=True, index=True)
appointment_type_id = Column(Integer, ForeignKey("master_appointment_types.id")) appointment_type_id = Column(Integer, ForeignKey("master_appointment_types.id"))
clinic_doctor_id = Column(Integer, ForeignKey("clinic_doctors.id")) clinic_doctor_id = Column(Integer, ForeignKey("clinic_doctors.id", ondelete="CASCADE"))
clinicDoctors = relationship("ClinicDoctors", back_populates="appointmentRelations") clinicDoctors = relationship("ClinicDoctors", back_populates="appointmentRelations")
masterAppointmentTypes = relationship("MasterAppointmentTypes", back_populates="appointmentRelations") masterAppointmentTypes = relationship("MasterAppointmentTypes", back_populates="appointmentRelations")