80 lines
3.9 KiB
Python
Raw Normal View History

2024-07-29 11:43:52 +08:00
"""empty message
Revision ID: 36b005d8e480
Revises: ef4643db2b6e
Create Date: 2023-04-23 21:24:19.183397
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision = '36b005d8e480'
down_revision = 'ef4643db2b6e'
branch_labels = None
depends_on = None
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_='foreignkey')
batch_op.create_foreign_key('reports_ibfk_1', 'appointment_info', ['appointment_id'], ['id'])
with op.batch_alter_table('call_numbers', schema=None) as batch_op:
batch_op.drop_constraint(None, type_='foreignkey')
batch_op.create_foreign_key('call_numbers_ibfk_1', 'appointment_info', ['appointment_id'], ['id'])
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_doccomments_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('email', 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('phone', mysql.VARCHAR(length=256), nullable=True),
sa.Column('age', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
sa.Column('id_number', mysql.VARCHAR(length=256), nullable=True),
sa.Column('time', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
sa.Column('location', mysql.VARCHAR(length=256), 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_email', ['email'], unique=False)
batch_op.create_index('ix_appointment_date', ['date'], unique=False)
with op.batch_alter_table('doccomments', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_doccomments_timestamp'))
op.drop_table('doccomments')
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.drop_table('appointment')
# ### end Alembic commands ###