"""Initial migration
Revision ID: 4546689d8c2d
Revises:
Create Date: 2025-06-15 00:02:28.751148
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '4546689d8c2d'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('doctors',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('first_name', sa.String(length=100), nullable=False),
sa.Column('last_name', sa.String(length=100), nullable=False),
sa.Column('email', sa.String(), nullable=True),
sa.Column('phone', sa.String(length=20), nullable=True),
sa.Column('specialization', sa.String(length=200), nullable=False),
sa.Column('license_number', sa.String(length=100), nullable=False),
sa.Column('years_of_experience', sa.Integer(), nullable=True),
sa.Column('bio', sa.Text(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id', name=op.f('pk_doctors')),
sa.UniqueConstraint('license_number', name=op.f('uq_doctors_license_number'))
)
op.create_index(op.f('ix_doctors_email'), 'doctors', ['email'], unique=True)
op.create_index(op.f('ix_doctors_id'), 'doctors', ['id'], unique=False)
op.create_table('patients',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('first_name', sa.String(length=100), nullable=False),
sa.Column('last_name', sa.String(length=100), nullable=False),
sa.Column('email', sa.String(), nullable=True),
sa.Column('phone', sa.String(length=20), nullable=True),
sa.Column('date_of_birth', sa.Date(), nullable=False),
sa.Column('gender', sa.Enum('MALE', 'FEMALE', 'OTHER', name='genderenum'), nullable=False),
sa.Column('address', sa.Text(), nullable=True),
sa.Column('emergency_contact_name', sa.String(length=200), nullable=True),
sa.Column('emergency_contact_phone', sa.String(length=20), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id', name=op.f('pk_patients'))
)
op.create_index(op.f('ix_patients_email'), 'patients', ['email'], unique=True)
op.create_index(op.f('ix_patients_id'), 'patients', ['id'], unique=False)
op.create_table('users',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('email', sa.String(), nullable=False),
sa.Column('username', sa.String(), nullable=False),
sa.Column('hashed_password', sa.String(), nullable=False),
sa.Column('is_active', sa.Boolean(), nullable=True),
sa.Column('is_superuser', sa.Boolean(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id', name=op.f('pk_users'))
)
op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
op.create_index(op.f('ix_users_id'), 'users', ['id'], unique=False)
op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True)
op.create_table('appointments',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('patient_id', sa.Integer(), nullable=False),
sa.Column('doctor_id', sa.Integer(), nullable=False),
sa.Column('appointment_datetime', sa.DateTime(timezone=True), nullable=False),
sa.Column('duration_minutes', sa.Integer(), nullable=True),
sa.Column('status', sa.Enum('SCHEDULED', 'CONFIRMED', 'IN_PROGRESS', 'COMPLETED', 'CANCELLED', 'NO_SHOW', name='appointmentstatusenum'), nullable=True),
sa.Column('reason', sa.String(length=500), nullable=True),
sa.Column('notes', sa.Text(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.ForeignKeyConstraint(['doctor_id'], ['doctors.id'], name=op.f('fk_appointments_doctor_id_doctors')),
sa.ForeignKeyConstraint(['patient_id'], ['patients.id'], name=op.f('fk_appointments_patient_id_patients')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_appointments'))
)
op.create_index(op.f('ix_appointments_id'), 'appointments', ['id'], unique=False)
op.create_table('medical_records',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('patient_id', sa.Integer(), nullable=False),
sa.Column('doctor_id', sa.Integer(), nullable=False),
sa.Column('visit_date', sa.DateTime(timezone=True), nullable=False),
sa.Column('diagnosis', sa.String(length=500), nullable=True),
sa.Column('symptoms', sa.Text(), nullable=True),
sa.Column('treatment', sa.Text(), nullable=True),
sa.Column('prescription', sa.Text(), nullable=True),
sa.Column('notes', sa.Text(), nullable=True),
sa.Column('blood_pressure_systolic', sa.Integer(), nullable=True),
sa.Column('blood_pressure_diastolic', sa.Integer(), nullable=True),
sa.Column('heart_rate', sa.Integer(), nullable=True),
sa.Column('temperature', sa.Float(), nullable=True),
sa.Column('weight', sa.Float(), nullable=True),
sa.Column('height', sa.Float(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.ForeignKeyConstraint(['doctor_id'], ['doctors.id'], name=op.f('fk_medical_records_doctor_id_doctors')),
sa.ForeignKeyConstraint(['patient_id'], ['patients.id'], name=op.f('fk_medical_records_patient_id_patients')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_medical_records'))
)
op.create_index(op.f('ix_medical_records_id'), 'medical_records', ['id'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_medical_records_id'), table_name='medical_records')
op.drop_table('medical_records')
op.drop_index(op.f('ix_appointments_id'), table_name='appointments')
op.drop_table('appointments')
op.drop_index(op.f('ix_users_username'), table_name='users')
op.drop_index(op.f('ix_users_id'), table_name='users')
op.drop_index(op.f('ix_users_email'), table_name='users')
op.drop_table('users')
op.drop_index(op.f('ix_patients_id'), table_name='patients')
op.drop_index(op.f('ix_patients_email'), table_name='patients')
op.drop_table('patients')
op.drop_index(op.f('ix_doctors_id'), table_name='doctors')
op.drop_index(op.f('ix_doctors_email'), table_name='doctors')
op.drop_table('doctors')
# ### end Alembic commands ###