"""empty message

Revision ID: 9c33f6742602
Revises: 228e22340dbe
Create Date: 2019-12-21 15:45:23.840096

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '<KEY>'
down_revision = '228e22340dbe'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('hspapply',
    sa.Column('hspid', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('doctor_ID', sa.CHAR(length=4), nullable=True),
    sa.Column('applyDate', sa.DATE(), nullable=True),
    sa.ForeignKeyConstraint(['doctor_ID'], ['medicalstaff.StaffID'], ),
    sa.PrimaryKeyConstraint('hspid')
    )
    op.create_table('nursing',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('nurseID', sa.CHAR(length=4), nullable=False),
    sa.Column('date', sa.DATE(), nullable=True),
    sa.Column('conditionDesc', sa.VARCHAR(length=200), nullable=True),
    sa.ForeignKeyConstraint(['id'], ['patient.id'], ),
    sa.ForeignKeyConstraint(['nurseID'], ['medicalstaff.StaffID'], ),
    sa.PrimaryKeyConstraint('id', 'nurseID')
    )
    op.create_table('hospitalization',
    sa.Column('bedNo', sa.CHAR(length=4), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('doctor_ID', sa.CHAR(length=4), nullable=True),
    sa.Column('nurse_ID', sa.CHAR(length=4), nullable=True),
    sa.Column('startDate', sa.DATE(), nullable=True),
    sa.Column('endDate', sa.DATE(), nullable=True),
    sa.Column('transferHospital', sa.CHAR(length=1), nullable=True),
    sa.ForeignKeyConstraint(['bedNo'], ['bed.bedNo'], ),
    sa.ForeignKeyConstraint(['doctor_ID'], ['medicalstaff.StaffID'], ),
    sa.ForeignKeyConstraint(['id'], ['patient.id'], ),
    sa.PrimaryKeyConstraint('bedNo', 'id')
    )
    op.create_table('prescription_detail',
    sa.Column('prescriptionID', sa.CHAR(length=5), nullable=False),
    sa.Column('medicine_ID', sa.CHAR(length=3), nullable=False),
    sa.Column('quantity', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['medicine_ID'], ['medicine.medicineID'], ),
    sa.PrimaryKeyConstraint('prescriptionID', 'medicine_ID')
    )
    op.add_column('bed', sa.Column('ward_No', sa.CHAR(length=10), nullable=True))
    op.create_foreign_key(None, 'bed', 'ward', ['ward_No'], ['wardNo'])
    op.add_column('medicalstaff', sa.Column('department_ID', sa.CHAR(length=3), nullable=True))
    op.create_foreign_key(None, 'medicalstaff', 'department', ['department_ID'], ['department_ID'])
    op.add_column('medicine', sa.Column('warehouse_ID', sa.CHAR(length=2), nullable=True))
    op.create_foreign_key(None, 'medicine', 'warehouse', ['warehouse_ID'], ['warehouseID'])
    op.add_column('prescription', sa.Column('doctor_ID', sa.CHAR(length=4), nullable=True))
    op.add_column('prescription', sa.Column('id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'prescription', 'medicalstaff', ['doctor_ID'], ['StaffID'])
    op.create_foreign_key(None, 'prescription', 'patient', ['id'], ['id'])
    op.add_column('reservation', sa.Column('doctor_ID', sa.CHAR(length=4), nullable=True))
    op.add_column('reservation', sa.Column('id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'reservation', 'patient', ['id'], ['id'])
    op.create_foreign_key(None, 'reservation', 'medicalstaff', ['doctor_ID'], ['StaffID'])
    op.add_column('ward', sa.Column('department_ID', sa.CHAR(length=3), nullable=True))
    op.create_foreign_key(None, 'ward', 'department', ['department_ID'], ['department_ID'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'ward', type_='foreignkey')
    op.drop_column('ward', 'department_ID')
    op.drop_constraint(None, 'reservation', type_='foreignkey')
    op.drop_constraint(None, 'reservation', type_='foreignkey')
    op.drop_column('reservation', 'id')
    op.drop_column('reservation', 'doctor_ID')
    op.drop_constraint(None, 'prescription', type_='foreignkey')
    op.drop_constraint(None, 'prescription', type_='foreignkey')
    op.drop_column('prescription', 'id')
    op.drop_column('prescription', 'doctor_ID')
    op.drop_constraint(None, 'medicine', type_='foreignkey')
    op.drop_column('medicine', 'warehouse_ID')
    op.drop_constraint(None, 'medicalstaff', type_='foreignkey')
    op.drop_column('medicalstaff', 'department_ID')
    op.drop_constraint(None, 'bed', type_='foreignkey')
    op.drop_column('bed', 'ward_No')
    op.drop_table('prescription_detail')
    op.drop_table('hospitalization')
    op.drop_table('nursing')
    op.drop_table('hspapply')
    # ### end Alembic commands ###

"""empty message

Revision ID: 9c33f6742602
Revises: 228e22340dbe
Create Date: 2019-12-21 15:45:23.840096

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '<KEY>'
down_revision = '228e22340dbe'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('hspapply',
    sa.Column('hspid', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('doctor_ID', sa.CHAR(length=4), nullable=True),
    sa.Column('applyDate', sa.DATE(), nullable=True),
    sa.ForeignKeyConstraint(['doctor_ID'], ['medicalstaff.StaffID'], ),
    sa.PrimaryKeyConstraint('hspid')
    )
    op.create_table('nursing',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('nurseID', sa.CHAR(length=4), nullable=False),
    sa.Column('date', sa.DATE(), nullable=True),
    sa.Column('conditionDesc', sa.VARCHAR(length=200), nullable=True),
    sa.ForeignKeyConstraint(['id'], ['patient.id'], ),
    sa.ForeignKeyConstraint(['nurseID'], ['medicalstaff.StaffID'], ),
    sa.PrimaryKeyConstraint('id', 'nurseID')
    )
    op.create_table('hospitalization',
    sa.Column('bedNo', sa.CHAR(length=4), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('doctor_ID', sa.CHAR(length=4), nullable=True),
    sa.Column('nurse_ID', sa.CHAR(length=4), nullable=True),
    sa.Column('startDate', sa.DATE(), nullable=True),
    sa.Column('endDate', sa.DATE(), nullable=True),
    sa.Column('transferHospital', sa.CHAR(length=1), nullable=True),
    sa.ForeignKeyConstraint(['bedNo'], ['bed.bedNo'], ),
    sa.ForeignKeyConstraint(['doctor_ID'], ['medicalstaff.StaffID'], ),
    sa.ForeignKeyConstraint(['id'], ['patient.id'], ),
    sa.PrimaryKeyConstraint('bedNo', 'id')
    )
    op.create_table('prescription_detail',
    sa.Column('prescriptionID', sa.CHAR(length=5), nullable=False),
    sa.Column('medicine_ID', sa.CHAR(length=3), nullable=False),
    sa.Column('quantity', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['medicine_ID'], ['medicine.medicineID'], ),
    sa.PrimaryKeyConstraint('prescriptionID', 'medicine_ID')
    )
    op.add_column('bed', sa.Column('ward_No', sa.CHAR(length=10), nullable=True))
    op.create_foreign_key(None, 'bed', 'ward', ['ward_No'], ['wardNo'])
    op.add_column('medicalstaff', sa.Column('department_ID', sa.CHAR(length=3), nullable=True))
    op.create_foreign_key(None, 'medicalstaff', 'department', ['department_ID'], ['department_ID'])
    op.add_column('medicine', sa.Column('warehouse_ID', sa.CHAR(length=2), nullable=True))
    op.create_foreign_key(None, 'medicine', 'warehouse', ['warehouse_ID'], ['warehouseID'])
    op.add_column('prescription', sa.Column('doctor_ID', sa.CHAR(length=4), nullable=True))
    op.add_column('prescription', sa.Column('id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'prescription', 'medicalstaff', ['doctor_ID'], ['StaffID'])
    op.create_foreign_key(None, 'prescription', 'patient', ['id'], ['id'])
    op.add_column('reservation', sa.Column('doctor_ID', sa.CHAR(length=4), nullable=True))
    op.add_column('reservation', sa.Column('id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'reservation', 'patient', ['id'], ['id'])
    op.create_foreign_key(None, 'reservation', 'medicalstaff', ['doctor_ID'], ['StaffID'])
    op.add_column('ward', sa.Column('department_ID', sa.CHAR(length=3), nullable=True))
    op.create_foreign_key(None, 'ward', 'department', ['department_ID'], ['department_ID'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'ward', type_='foreignkey')
    op.drop_column('ward', 'department_ID')
    op.drop_constraint(None, 'reservation', type_='foreignkey')
    op.drop_constraint(None, 'reservation', type_='foreignkey')
    op.drop_column('reservation', 'id')
    op.drop_column('reservation', 'doctor_ID')
    op.drop_constraint(None, 'prescription', type_='foreignkey')
    op.drop_constraint(None, 'prescription', type_='foreignkey')
    op.drop_column('prescription', 'id')
    op.drop_column('prescription', 'doctor_ID')
    op.drop_constraint(None, 'medicine', type_='foreignkey')
    op.drop_column('medicine', 'warehouse_ID')
    op.drop_constraint(None, 'medicalstaff', type_='foreignkey')
    op.drop_column('medicalstaff', 'department_ID')
    op.drop_constraint(None, 'bed', type_='foreignkey')
    op.drop_column('bed', 'ward_No')
    op.drop_table('prescription_detail')
    op.drop_table('hospitalization')
    op.drop_table('nursing')
    op.drop_table('hspapply')
    # ### end Alembic commands ###

empty message  Revision ID: 9c33f6742602 Revises: 228e22340dbe Create Date: 2019-12-21 15:45:23.840096 # revision identifiers, used by Alembic. # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ### # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ###