97 lines
4.5 KiB
Python
97 lines
4.5 KiB
Python
|
"""empty message
|
||
|
|
||
|
Revision ID: ef4643db2b6e
|
||
|
Revises: bb3518c7dc22
|
||
|
Create Date: 2023-04-23 21:19:56.976825
|
||
|
|
||
|
"""
|
||
|
from alembic import op
|
||
|
import sqlalchemy as sa
|
||
|
from sqlalchemy.dialects import mysql
|
||
|
|
||
|
# revision identifiers, used by Alembic.
|
||
|
revision = 'ef4643db2b6e'
|
||
|
down_revision = 'bb3518c7dc22'
|
||
|
branch_labels = None
|
||
|
depends_on = None
|
||
|
|
||
|
|
||
|
def upgrade():
|
||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
with op.batch_alter_table('appointment_info', schema=None) as batch_op:
|
||
|
batch_op.drop_index('ix_appointment_info_date')
|
||
|
batch_op.drop_index('ix_appointment_info_email')
|
||
|
|
||
|
op.drop_table('appointment_info')
|
||
|
with op.batch_alter_table('comment_fordoc', schema=None) as batch_op:
|
||
|
batch_op.drop_index('ix_comment_fordoc_timestamp')
|
||
|
|
||
|
op.drop_table('comment_fordoc')
|
||
|
with op.batch_alter_table('appointment', schema=None) as batch_op:
|
||
|
batch_op.create_index(batch_op.f('ix_appointment_date'), ['date'], unique=False)
|
||
|
batch_op.create_index(batch_op.f('ix_appointment_email'), ['email'], unique=False)
|
||
|
|
||
|
with op.batch_alter_table('call_numbers', schema=None) as batch_op:
|
||
|
batch_op.create_unique_constraint(None, ['appointment_id'])
|
||
|
|
||
|
with op.batch_alter_table('reports', schema=None) as batch_op:
|
||
|
batch_op.create_unique_constraint(None, ['appointment_id'])
|
||
|
|
||
|
# ### end Alembic commands ###
|
||
|
|
||
|
|
||
|
def downgrade():
|
||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
with op.batch_alter_table('reports', schema=None) as batch_op:
|
||
|
batch_op.drop_constraint(None, type_='unique')
|
||
|
|
||
|
with op.batch_alter_table('call_numbers', schema=None) as batch_op:
|
||
|
batch_op.drop_constraint(None, type_='unique')
|
||
|
|
||
|
with op.batch_alter_table('appointment', schema=None) as batch_op:
|
||
|
batch_op.drop_index(batch_op.f('ix_appointment_email'))
|
||
|
batch_op.drop_index(batch_op.f('ix_appointment_date'))
|
||
|
|
||
|
op.create_table('comment_fordoc',
|
||
|
sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False),
|
||
|
sa.Column('body', mysql.TEXT(), nullable=True),
|
||
|
sa.Column('timestamp', mysql.DATETIME(), nullable=True),
|
||
|
sa.Column('author_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
|
||
|
sa.Column('doc_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
|
||
|
sa.Column('star_num', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
|
||
|
sa.ForeignKeyConstraint(['author_id'], ['users.id'], name='comment_fordoc_ibfk_1'),
|
||
|
sa.ForeignKeyConstraint(['doc_id'], ['users.id'], name='comment_fordoc_ibfk_2'),
|
||
|
sa.PrimaryKeyConstraint('id'),
|
||
|
mysql_default_charset='utf8',
|
||
|
mysql_engine='InnoDB'
|
||
|
)
|
||
|
with op.batch_alter_table('comment_fordoc', schema=None) as batch_op:
|
||
|
batch_op.create_index('ix_comment_fordoc_timestamp', ['timestamp'], unique=False)
|
||
|
|
||
|
op.create_table('appointment_info',
|
||
|
sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False),
|
||
|
sa.Column('patient_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
|
||
|
sa.Column('doc_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
|
||
|
sa.Column('date', sa.DATE(), nullable=True),
|
||
|
sa.Column('time', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
|
||
|
sa.Column('email', mysql.VARCHAR(length=256), nullable=True),
|
||
|
sa.Column('id_number', mysql.VARCHAR(length=256), nullable=True),
|
||
|
sa.Column('name', mysql.VARCHAR(length=256), nullable=True),
|
||
|
sa.Column('gender', mysql.VARCHAR(length=256), nullable=True),
|
||
|
sa.Column('location', mysql.VARCHAR(length=256), nullable=True),
|
||
|
sa.Column('phone', mysql.VARCHAR(length=256), nullable=True),
|
||
|
sa.Column('age', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
|
||
|
sa.Column('cost', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
|
||
|
sa.Column('num', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
|
||
|
sa.ForeignKeyConstraint(['doc_id'], ['users.id'], name='appointment_info_ibfk_1'),
|
||
|
sa.ForeignKeyConstraint(['patient_id'], ['users.id'], name='appointment_info_ibfk_2'),
|
||
|
sa.PrimaryKeyConstraint('id'),
|
||
|
mysql_default_charset='utf8',
|
||
|
mysql_engine='InnoDB'
|
||
|
)
|
||
|
with op.batch_alter_table('appointment_info', schema=None) as batch_op:
|
||
|
batch_op.create_index('ix_appointment_info_email', ['email'], unique=False)
|
||
|
batch_op.create_index('ix_appointment_info_date', ['date'], unique=False)
|
||
|
|
||
|
# ### end Alembic commands ###
|