kinit/kinit-api/alembic/versions/0cd7a858c5a5_update.py
2022-09-16 12:32:51 +08:00

67 lines
3.8 KiB
Python

"""update
Revision ID: 0cd7a858c5a5
Revises: bc1417d96581
Create Date: 2022-08-08 12:39:32.344065
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '0cd7a858c5a5'
down_revision = 'bc1417d96581'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('vadmin_system_dict_type',
sa.Column('id', sa.Integer(), nullable=False, comment='主键ID'),
sa.Column('create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'),
sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'),
sa.Column('dict_name', sa.String(length=50), nullable=False, comment='字典名称'),
sa.Column('dict_type', sa.String(length=50), nullable=False, comment='字典类型'),
sa.Column('status', sa.Boolean(), nullable=True, comment='字典状态,是否可用'),
sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'),
sa.PrimaryKeyConstraint('id'),
comment='字典类型表'
)
op.create_index(op.f('ix_vadmin_system_dict_type_dict_name'), 'vadmin_system_dict_type', ['dict_name'], unique=False)
op.create_index(op.f('ix_vadmin_system_dict_type_dict_type'), 'vadmin_system_dict_type', ['dict_type'], unique=False)
op.create_index(op.f('ix_vadmin_system_dict_type_id'), 'vadmin_system_dict_type', ['id'], unique=True)
op.create_table('vadmin_system_dict_details',
sa.Column('id', sa.Integer(), nullable=False, comment='主键ID'),
sa.Column('create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'),
sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'),
sa.Column('dict_label', sa.String(length=50), nullable=False, comment='字典标签'),
sa.Column('dict_value', sa.String(length=50), nullable=False, comment='字典键值'),
sa.Column('status', sa.Boolean(), nullable=True, comment='字典状态,是否可用'),
sa.Column('is_default', sa.Boolean(), nullable=True, comment='是否默认'),
sa.Column('sort', sa.Integer(), nullable=True, comment='字典排序'),
sa.Column('dict_type_id', sa.Integer(), nullable=True, comment='关联字典类型'),
sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'),
sa.ForeignKeyConstraint(['dict_type_id'], ['vadmin_system_dict_type.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
comment='字典详情表'
)
op.create_index(op.f('ix_vadmin_system_dict_details_dict_label'), 'vadmin_system_dict_details', ['dict_label'], unique=False)
op.create_index(op.f('ix_vadmin_system_dict_details_dict_value'), 'vadmin_system_dict_details', ['dict_value'], unique=False)
op.create_index(op.f('ix_vadmin_system_dict_details_id'), 'vadmin_system_dict_details', ['id'], unique=True)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_vadmin_system_dict_details_id'), table_name='vadmin_system_dict_details')
op.drop_index(op.f('ix_vadmin_system_dict_details_dict_value'), table_name='vadmin_system_dict_details')
op.drop_index(op.f('ix_vadmin_system_dict_details_dict_label'), table_name='vadmin_system_dict_details')
op.drop_table('vadmin_system_dict_details')
op.drop_index(op.f('ix_vadmin_system_dict_type_id'), table_name='vadmin_system_dict_type')
op.drop_index(op.f('ix_vadmin_system_dict_type_dict_type'), table_name='vadmin_system_dict_type')
op.drop_index(op.f('ix_vadmin_system_dict_type_dict_name'), table_name='vadmin_system_dict_type')
op.drop_table('vadmin_system_dict_type')
# ### end Alembic commands ###