将数据操作全部改为迁移脚本
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"""changge
|
||||
|
||||
Revision ID: 0893a714a376
|
||||
Revises: 296c80a9d6e8
|
||||
Create Date: 2021-06-14 01:21:16.185099
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0893a714a376'
|
||||
down_revision = '296c80a9d6e8'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_foreign_key(None, 'admin_power', 'admin_power', ['parent_id'], ['id'])
|
||||
op.create_foreign_key(None, 'admin_role_power', 'admin_role', ['role_id'], ['id'])
|
||||
op.create_foreign_key(None, 'admin_role_power', 'admin_power', ['power_id'], ['id'])
|
||||
op.create_foreign_key(None, 'admin_user_role', 'admin_role', ['role_id'], ['id'])
|
||||
op.create_foreign_key(None, 'admin_user_role', 'admin_user', ['user_id'], ['id'])
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(None, 'admin_user_role', type_='foreignkey')
|
||||
op.drop_constraint(None, 'admin_user_role', type_='foreignkey')
|
||||
op.drop_constraint(None, 'admin_role_power', type_='foreignkey')
|
||||
op.drop_constraint(None, 'admin_role_power', type_='foreignkey')
|
||||
op.drop_constraint(None, 'admin_power', type_='foreignkey')
|
||||
# ### end Alembic commands ###
|
||||
@@ -1,8 +1,8 @@
|
||||
"""empty message
|
||||
"""init
|
||||
|
||||
Revision ID: ec21e19825ff
|
||||
Revision ID: 296c80a9d6e8
|
||||
Revises:
|
||||
Create Date: 2021-04-27 11:54:00.453274
|
||||
Create Date: 2021-06-14 00:44:22.947817
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
@@ -10,7 +10,7 @@ import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'ec21e19825ff'
|
||||
revision = '296c80a9d6e8'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
@@ -30,6 +30,21 @@ def upgrade():
|
||||
sa.Column('create_time', sa.DateTime(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('admin_dept',
|
||||
sa.Column('id', sa.Integer(), nullable=False, comment='部门ID'),
|
||||
sa.Column('parent_id', sa.Integer(), nullable=True, comment='父级编号'),
|
||||
sa.Column('dept_name', sa.String(length=50), nullable=True, comment='部门名称'),
|
||||
sa.Column('sort', sa.Integer(), nullable=True, comment='排序'),
|
||||
sa.Column('leader', sa.String(length=50), nullable=True, comment='负责人'),
|
||||
sa.Column('phone', sa.String(length=20), nullable=True, comment='联系方式'),
|
||||
sa.Column('email', sa.String(length=50), nullable=True, comment='邮箱'),
|
||||
sa.Column('status', sa.Integer(), nullable=True, comment='状态(1开启,0关闭)'),
|
||||
sa.Column('remark', sa.Text(), nullable=True, comment='备注'),
|
||||
sa.Column('address', sa.String(length=255), nullable=True, comment='详细地址'),
|
||||
sa.Column('create_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.Column('update_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('admin_dict_data',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('data_label', sa.String(length=255), nullable=True, comment='字典类型名称'),
|
||||
@@ -64,16 +79,17 @@ def upgrade():
|
||||
op.create_table('admin_power',
|
||||
sa.Column('id', sa.Integer(), nullable=False, comment='权限编号'),
|
||||
sa.Column('name', sa.String(length=255), nullable=True, comment='权限名称'),
|
||||
sa.Column('type', sa.String(length=1), nullable=True, comment='权限类型'),
|
||||
sa.Column('type', sa.SmallInteger(), nullable=True, comment='权限类型'),
|
||||
sa.Column('code', sa.String(length=30), nullable=True, comment='权限标识'),
|
||||
sa.Column('url', sa.String(length=255), nullable=True, comment='权限路径'),
|
||||
sa.Column('open_type', sa.String(length=10), nullable=True, comment='打开方式'),
|
||||
sa.Column('parent_id', sa.Integer(), nullable=True, comment='父类编号'),
|
||||
sa.Column('icon', sa.String(length=128), nullable=True, comment='图标'),
|
||||
sa.Column('sort', sa.Integer(), nullable=True, comment='排序'),
|
||||
sa.Column('create_time', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.Column('update_time', sa.DateTime(), nullable=True, comment='更新时间'),
|
||||
sa.Column('enable', sa.Integer(), nullable=True, comment='是否开启'),
|
||||
sa.Column('parent_id', sa.Integer(), nullable=True, comment='父类编号'),
|
||||
sa.ForeignKeyConstraint(['parent_id'], ['admin_power.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('admin_role',
|
||||
@@ -96,6 +112,7 @@ def upgrade():
|
||||
sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'),
|
||||
sa.Column('password_hash', sa.String(length=128), nullable=True, comment='哈希密码'),
|
||||
sa.Column('enable', sa.Integer(), nullable=True, comment='启用'),
|
||||
sa.Column('dept_id', sa.Integer(), nullable=True, comment='部门id'),
|
||||
sa.Column('create_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.Column('update_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
@@ -129,5 +146,6 @@ def downgrade():
|
||||
op.drop_table('admin_photo')
|
||||
op.drop_table('admin_dict_type')
|
||||
op.drop_table('admin_dict_data')
|
||||
op.drop_table('admin_dept')
|
||||
op.drop_table('admin_admin_log')
|
||||
# ### end Alembic commands ###
|
||||
@@ -1,28 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 7634e028e338
|
||||
Revises: 8b664608a7c7
|
||||
Create Date: 2021-06-01 16:43:50.853692
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '7634e028e338'
|
||||
down_revision = '8b664608a7c7'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('admin_user', sa.Column('dept_id', sa.Integer(), nullable=True, comment='部门id'))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('admin_user', 'dept_id')
|
||||
# ### end Alembic commands ###
|
||||
@@ -1,42 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 8b664608a7c7
|
||||
Revises: ec21e19825ff
|
||||
Create Date: 2021-06-01 14:37:20.327189
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '8b664608a7c7'
|
||||
down_revision = 'ec21e19825ff'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('admin_dept',
|
||||
sa.Column('id', sa.Integer(), nullable=False, comment='部门ID'),
|
||||
sa.Column('parent_id', sa.Integer(), nullable=True, comment='父级编号'),
|
||||
sa.Column('dept_name', sa.String(length=50), nullable=True, comment='部门名称'),
|
||||
sa.Column('sort', sa.Integer(), nullable=True, comment='排序'),
|
||||
sa.Column('leader', sa.String(length=50), nullable=True, comment='负责人'),
|
||||
sa.Column('phone', sa.String(length=20), nullable=True, comment='联系方式'),
|
||||
sa.Column('email', sa.String(length=50), nullable=True, comment='邮箱'),
|
||||
sa.Column('status', sa.Integer(), nullable=True, comment='状态(1开启,0关闭)'),
|
||||
sa.Column('remark', sa.Text(), nullable=True, comment='备注'),
|
||||
sa.Column('address', sa.String(length=255), nullable=True, comment='详细地址'),
|
||||
sa.Column('create_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.Column('update_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('admin_dept')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user