mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 12:52:26 +00:00
260 lines
17 KiB
Python
260 lines
17 KiB
Python
"""解决上传config字段长度限制
|
|
|
|
Revision ID: 6581efd64942
|
|
Revises:
|
|
Create Date: 2025-03-29 00:02:03.024491
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = '6581efd64942'
|
|
down_revision: Union[str, None] = None
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('system_dept',
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='主键ID'),
|
|
sa.Column('name', sa.String(length=40), nullable=False, comment='部门名称'),
|
|
sa.Column('order', sa.Integer(), nullable=False, comment='显示排序'),
|
|
sa.Column('parent_id', sa.Integer(), nullable=True, comment='父级部门ID'),
|
|
sa.Column('available', sa.Boolean(), nullable=False, comment='是否启用(True:启用 False:禁用)'),
|
|
sa.Column('description', sa.Text(), nullable=True, comment='备注说明'),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
|
sa.ForeignKeyConstraint(['parent_id'], ['system_dept.id'], onupdate='CASCADE', ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('id'),
|
|
sa.UniqueConstraint('name'),
|
|
comment='部门表'
|
|
)
|
|
op.create_index(op.f('ix_system_dept_parent_id'), 'system_dept', ['parent_id'], unique=False)
|
|
op.create_table('system_menu',
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='主键ID'),
|
|
sa.Column('name', sa.String(length=50), nullable=False, comment='菜单名称'),
|
|
sa.Column('type', sa.Integer(), nullable=False, comment='菜单类型'),
|
|
sa.Column('order', sa.Integer(), nullable=False, comment='显示排序'),
|
|
sa.Column('permission', sa.String(length=100), nullable=True, comment='权限标识(如:system:user:list)'),
|
|
sa.Column('available', sa.Boolean(), nullable=False, comment='是否启用(True:启用 False:禁用)'),
|
|
sa.Column('icon', sa.String(length=50), nullable=True, comment='菜单图标'),
|
|
sa.Column('route_name', sa.String(length=100), nullable=True, comment='路由名称'),
|
|
sa.Column('route_path', sa.String(length=200), nullable=True, comment='路由路径'),
|
|
sa.Column('component_path', sa.String(length=200), nullable=True, comment='组件路径'),
|
|
sa.Column('redirect', sa.String(length=200), nullable=True, comment='重定向地址'),
|
|
sa.Column('hidden', sa.Boolean(), nullable=False, comment='是否隐藏(True:隐藏 False:显示)'),
|
|
sa.Column('cache', sa.Boolean(), nullable=False, comment='是否缓存(True:是 False:否)'),
|
|
sa.Column('parent_id', sa.Integer(), nullable=True, comment='父级菜单ID'),
|
|
sa.Column('description', sa.Text(), nullable=True, comment='备注说明'),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
|
sa.ForeignKeyConstraint(['parent_id'], ['system_menu.id'], onupdate='CASCADE', ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('id'),
|
|
sa.UniqueConstraint('name'),
|
|
comment='菜单表'
|
|
)
|
|
op.create_index(op.f('ix_system_menu_parent_id'), 'system_menu', ['parent_id'], unique=False)
|
|
op.create_table('system_users',
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='主键ID'),
|
|
sa.Column('username', sa.String(length=150), nullable=False, comment='用户名/登录账号'),
|
|
sa.Column('password', sa.String(length=128), nullable=False, comment='密码'),
|
|
sa.Column('name', sa.String(length=40), nullable=False, comment='姓名'),
|
|
sa.Column('mobile', sa.String(length=20), nullable=True, comment='手机号'),
|
|
sa.Column('email', sa.String(length=255), nullable=True, comment='邮箱'),
|
|
sa.Column('gender', sa.Integer(), nullable=False, comment='性别(1:男 2:女 3:未知)'),
|
|
sa.Column('avatar', sa.String(length=255), nullable=True, comment='头像地址'),
|
|
sa.Column('available', sa.Boolean(), nullable=False, comment='是否启用(True:启用 False:禁用)'),
|
|
sa.Column('is_superuser', sa.Boolean(), nullable=False, comment='是否为超级管理员'),
|
|
sa.Column('last_login', sa.DateTime(), nullable=True, comment='最后登录时间'),
|
|
sa.Column('dept_id', sa.Integer(), nullable=True, comment='部门ID'),
|
|
sa.Column('description', sa.Text(), nullable=True, comment='备注说明'),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
|
sa.Column('creator_id', sa.Integer(), nullable=True, comment='创建人ID'),
|
|
sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'),
|
|
sa.ForeignKeyConstraint(['dept_id'], ['system_dept.id'], onupdate='CASCADE', ondelete='SET NULL'),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('id'),
|
|
sa.UniqueConstraint('username'),
|
|
comment='用户表'
|
|
)
|
|
op.create_index(op.f('ix_system_users_creator_id'), 'system_users', ['creator_id'], unique=False)
|
|
op.create_index(op.f('ix_system_users_dept_id'), 'system_users', ['dept_id'], unique=False)
|
|
op.create_table('system_config',
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='主键ID'),
|
|
sa.Column('title', sa.String(length=100), nullable=False, comment='网站标题'),
|
|
sa.Column('favicon', sa.String(length=500), nullable=False, comment='网站favicon'),
|
|
sa.Column('logo', sa.String(length=500), nullable=False, comment='网站logo'),
|
|
sa.Column('background', sa.String(length=500), nullable=False, comment='网站背景'),
|
|
sa.Column('copyright', sa.String(length=500), nullable=False, comment='版权信息'),
|
|
sa.Column('keep_record', sa.String(length=500), nullable=False, comment='备案信息'),
|
|
sa.Column('help_url', sa.String(length=500), nullable=False, comment='帮助链接'),
|
|
sa.Column('privacy_url', sa.String(length=500), nullable=False, comment='隐私政策链接'),
|
|
sa.Column('clause_url', sa.String(length=500), nullable=False, comment='服务条款链接'),
|
|
sa.Column('code_url', sa.String(length=500), nullable=False, comment='源码地址'),
|
|
sa.Column('description', sa.Text(), nullable=True, comment='备注说明'),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
|
sa.Column('creator_id', sa.Integer(), nullable=True, comment='创建人ID'),
|
|
sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('id'),
|
|
comment='配置表'
|
|
)
|
|
op.create_index(op.f('ix_system_config_creator_id'), 'system_config', ['creator_id'], unique=False)
|
|
op.create_table('system_notice',
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='主键ID'),
|
|
sa.Column('notice_title', sa.String(length=50), nullable=False, comment='公告标题'),
|
|
sa.Column('notice_type', sa.Integer(), nullable=False, comment='公告类型(1通知 2公告)'),
|
|
sa.Column('notice_content', sa.Text(), nullable=True, comment='公告内容'),
|
|
sa.Column('available', sa.Boolean(), nullable=False, comment='是否启用(True:启用 False:禁用)'),
|
|
sa.Column('description', sa.Text(), nullable=True, comment='备注说明'),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
|
sa.Column('creator_id', sa.Integer(), nullable=True, comment='创建人ID'),
|
|
sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('id'),
|
|
comment='通知公告表'
|
|
)
|
|
op.create_index(op.f('ix_system_notice_creator_id'), 'system_notice', ['creator_id'], unique=False)
|
|
op.create_table('system_operation_log',
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='主键ID'),
|
|
sa.Column('request_path', sa.String(length=255), nullable=True, comment='请求路径'),
|
|
sa.Column('request_method', sa.String(length=10), nullable=True, comment='请求方式'),
|
|
sa.Column('request_payload', sa.Text(), nullable=True, comment='请求体'),
|
|
sa.Column('request_ip', sa.String(length=50), nullable=True, comment='请求IP地址'),
|
|
sa.Column('request_os', sa.String(length=64), nullable=True, comment='操作系统'),
|
|
sa.Column('request_browser', sa.String(length=64), nullable=True, comment='浏览器'),
|
|
sa.Column('response_code', sa.Integer(), nullable=True, comment='响应状态码'),
|
|
sa.Column('response_json', sa.Text(), nullable=True, comment='响应体'),
|
|
sa.Column('description', sa.Text(), nullable=True, comment='备注说明'),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
|
sa.Column('creator_id', sa.Integer(), nullable=True, comment='创建人ID'),
|
|
sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('id'),
|
|
comment='操作日志表'
|
|
)
|
|
op.create_index(op.f('ix_system_operation_log_creator_id'), 'system_operation_log', ['creator_id'], unique=False)
|
|
op.create_index(op.f('ix_system_operation_log_request_method'), 'system_operation_log', ['request_method'], unique=False)
|
|
op.create_index(op.f('ix_system_operation_log_request_path'), 'system_operation_log', ['request_path'], unique=False)
|
|
op.create_table('system_position',
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='主键ID'),
|
|
sa.Column('name', sa.String(length=40), nullable=False, comment='岗位名称'),
|
|
sa.Column('order', sa.Integer(), nullable=False, comment='显示排序'),
|
|
sa.Column('available', sa.Boolean(), nullable=False, comment='是否启用(True:启用 False:禁用)'),
|
|
sa.Column('description', sa.Text(), nullable=True, comment='备注说明'),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
|
sa.Column('creator_id', sa.Integer(), nullable=True, comment='创建人ID'),
|
|
sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('id'),
|
|
sa.UniqueConstraint('name'),
|
|
comment='岗位表'
|
|
)
|
|
op.create_index(op.f('ix_system_position_creator_id'), 'system_position', ['creator_id'], unique=False)
|
|
op.create_table('system_role',
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='主键ID'),
|
|
sa.Column('name', sa.String(length=40), nullable=False, comment='角色名称'),
|
|
sa.Column('order', sa.Integer(), nullable=False, comment='显示排序'),
|
|
sa.Column('data_scope', sa.Integer(), nullable=False, comment='数据权限范围'),
|
|
sa.Column('available', sa.Boolean(), nullable=False, comment='是否启用(True:启用 False:禁用)'),
|
|
sa.Column('description', sa.Text(), nullable=True, comment='备注说明'),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
|
sa.Column('creator_id', sa.Integer(), nullable=True, comment='创建人ID'),
|
|
sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('id'),
|
|
sa.UniqueConstraint('name'),
|
|
comment='角色表'
|
|
)
|
|
op.create_index(op.f('ix_system_role_creator_id'), 'system_role', ['creator_id'], unique=False)
|
|
op.create_table('system_role_depts',
|
|
sa.Column('role_id', sa.Integer(), nullable=False, comment='角色ID'),
|
|
sa.Column('dept_id', sa.Integer(), nullable=False, comment='部门ID'),
|
|
sa.ForeignKeyConstraint(['dept_id'], ['system_dept.id'], onupdate='CASCADE', ondelete='CASCADE'),
|
|
sa.ForeignKeyConstraint(['role_id'], ['system_role.id'], onupdate='CASCADE', ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('role_id', 'dept_id'),
|
|
comment='角色部门关联表'
|
|
)
|
|
op.create_index(op.f('ix_system_role_depts_dept_id'), 'system_role_depts', ['dept_id'], unique=False)
|
|
op.create_index(op.f('ix_system_role_depts_role_id'), 'system_role_depts', ['role_id'], unique=False)
|
|
op.create_table('system_role_menus',
|
|
sa.Column('role_id', sa.Integer(), nullable=False, comment='角色ID'),
|
|
sa.Column('menu_id', sa.Integer(), nullable=False, comment='菜单ID'),
|
|
sa.ForeignKeyConstraint(['menu_id'], ['system_menu.id'], onupdate='CASCADE', ondelete='CASCADE'),
|
|
sa.ForeignKeyConstraint(['role_id'], ['system_role.id'], onupdate='CASCADE', ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('role_id', 'menu_id'),
|
|
comment='角色菜单关联表'
|
|
)
|
|
op.create_index(op.f('ix_system_role_menus_menu_id'), 'system_role_menus', ['menu_id'], unique=False)
|
|
op.create_index(op.f('ix_system_role_menus_role_id'), 'system_role_menus', ['role_id'], unique=False)
|
|
op.create_table('system_user_positions',
|
|
sa.Column('user_id', sa.Integer(), nullable=False, comment='用户ID'),
|
|
sa.Column('position_id', sa.Integer(), nullable=False, comment='岗位ID'),
|
|
sa.ForeignKeyConstraint(['position_id'], ['system_position.id'], onupdate='CASCADE', ondelete='CASCADE'),
|
|
sa.ForeignKeyConstraint(['user_id'], ['system_users.id'], onupdate='CASCADE', ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('user_id', 'position_id'),
|
|
comment='用户岗位关联表'
|
|
)
|
|
op.create_index(op.f('ix_system_user_positions_position_id'), 'system_user_positions', ['position_id'], unique=False)
|
|
op.create_index(op.f('ix_system_user_positions_user_id'), 'system_user_positions', ['user_id'], unique=False)
|
|
op.create_table('system_user_roles',
|
|
sa.Column('user_id', sa.Integer(), nullable=False, comment='用户ID'),
|
|
sa.Column('role_id', sa.Integer(), nullable=False, comment='角色ID'),
|
|
sa.ForeignKeyConstraint(['role_id'], ['system_role.id'], onupdate='CASCADE', ondelete='CASCADE'),
|
|
sa.ForeignKeyConstraint(['user_id'], ['system_users.id'], onupdate='CASCADE', ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('user_id', 'role_id'),
|
|
comment='用户角色关联表'
|
|
)
|
|
op.create_index(op.f('ix_system_user_roles_role_id'), 'system_user_roles', ['role_id'], unique=False)
|
|
op.create_index(op.f('ix_system_user_roles_user_id'), 'system_user_roles', ['user_id'], unique=False)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f('ix_system_user_roles_user_id'), table_name='system_user_roles')
|
|
op.drop_index(op.f('ix_system_user_roles_role_id'), table_name='system_user_roles')
|
|
op.drop_table('system_user_roles')
|
|
op.drop_index(op.f('ix_system_user_positions_user_id'), table_name='system_user_positions')
|
|
op.drop_index(op.f('ix_system_user_positions_position_id'), table_name='system_user_positions')
|
|
op.drop_table('system_user_positions')
|
|
op.drop_index(op.f('ix_system_role_menus_role_id'), table_name='system_role_menus')
|
|
op.drop_index(op.f('ix_system_role_menus_menu_id'), table_name='system_role_menus')
|
|
op.drop_table('system_role_menus')
|
|
op.drop_index(op.f('ix_system_role_depts_role_id'), table_name='system_role_depts')
|
|
op.drop_index(op.f('ix_system_role_depts_dept_id'), table_name='system_role_depts')
|
|
op.drop_table('system_role_depts')
|
|
op.drop_index(op.f('ix_system_role_creator_id'), table_name='system_role')
|
|
op.drop_table('system_role')
|
|
op.drop_index(op.f('ix_system_position_creator_id'), table_name='system_position')
|
|
op.drop_table('system_position')
|
|
op.drop_index(op.f('ix_system_operation_log_request_path'), table_name='system_operation_log')
|
|
op.drop_index(op.f('ix_system_operation_log_request_method'), table_name='system_operation_log')
|
|
op.drop_index(op.f('ix_system_operation_log_creator_id'), table_name='system_operation_log')
|
|
op.drop_table('system_operation_log')
|
|
op.drop_index(op.f('ix_system_notice_creator_id'), table_name='system_notice')
|
|
op.drop_table('system_notice')
|
|
op.drop_index(op.f('ix_system_config_creator_id'), table_name='system_config')
|
|
op.drop_table('system_config')
|
|
op.drop_index(op.f('ix_system_users_dept_id'), table_name='system_users')
|
|
op.drop_index(op.f('ix_system_users_creator_id'), table_name='system_users')
|
|
op.drop_table('system_users')
|
|
op.drop_index(op.f('ix_system_menu_parent_id'), table_name='system_menu')
|
|
op.drop_table('system_menu')
|
|
op.drop_index(op.f('ix_system_dept_parent_id'), table_name='system_dept')
|
|
op.drop_table('system_dept')
|
|
# ### end Alembic commands ###
|