forked from iti-framework/iTi-Flask
feat: 修复优化一些逻辑; 自研一个上传算法; 修正gitignore; 切换开发环境为mysql;
parent
269d453e07
commit
dd3ccff514
@ -1,7 +1,7 @@
|
||||
FLASK_ENV=prod
|
||||
SECRET_KEY=zhSYJn577LgxyWDuQboM9wX3j2BHEFUP
|
||||
JWT_SECRET_KEY=8YD37VvM3WgdpmKNt7kVFNbKnya4hBRh
|
||||
DATABASE_URL=sqlite:///runtime/iti-flask_dev.db
|
||||
DATABASE_URL=mysql+pymysql://root:root@127.0.0.1:3307/iti-flask?charset=utf8mb4
|
||||
# 前端相关
|
||||
FRONTEND_ENABLED=False # 是否启用前端渲染
|
||||
FRONTEND_PATH=dist # 前端文件所在位置,若static则无需填写
|
||||
@ -0,0 +1 @@
|
||||
from .sys import *
|
||||
@ -1,11 +1,12 @@
|
||||
from .sys_user import User, UserSchema
|
||||
from .sys_role import Role, RoleSchema
|
||||
from .sys_rel_user_role import sys_user_role
|
||||
from .sys_rel_role_menu import sys_role_menu
|
||||
from .sys_log import SysLog, LogSchema
|
||||
from .sys_config import SysConfig, SysConfigSchema
|
||||
from .sys_dict import SysDictType, SysDictTypeSchema, SysDictData, SysDictDataSchema
|
||||
from .sys_dept import SysDept, SysDeptSchema
|
||||
from .sys_rel_user_dept import sys_user_dept
|
||||
from .sys_menu import SysMenu, SysMenuSchema, SysMenuMetaSchema
|
||||
from .sys_file import SysFile, SysFileSchema, SysFileDirectory, SysFileDirectorySchema
|
||||
from .sys.sys_user import User, UserSchema
|
||||
from .sys.sys_user_attribute import SysUserAttribute, SysUserAttributeSchema
|
||||
from .sys.sys_role import Role, RoleSchema
|
||||
from .sys.sys_rel_user_role import sys_user_role
|
||||
from .sys.sys_rel_role_menu import sys_role_menu
|
||||
from .sys.sys_log import SysLog, LogSchema
|
||||
from .sys.sys_config import SysConfig, SysConfigSchema
|
||||
from .sys.sys_dict import SysDictType, SysDictTypeSchema, SysDictData, SysDictDataSchema
|
||||
from .sys.sys_dept import SysDept, SysDeptSchema
|
||||
from .sys.sys_rel_user_dept import sys_user_dept
|
||||
from .sys.sys_menu import SysMenu, SysMenuSchema, SysMenuMetaSchema
|
||||
from .sys.sys_file import SysFile, SysFileSchema, SysFileDirectory, SysFileDirectorySchema
|
||||
|
||||
@ -0,0 +1,108 @@
|
||||
from iti.applications.extensions import db
|
||||
from iti.applications.common.crud import BaseModelMixin
|
||||
from iti.applications.common.utils import BaseSchema
|
||||
from apiflask.fields import String, Integer
|
||||
|
||||
|
||||
class SysUserAttribute(BaseModelMixin):
|
||||
"""
|
||||
用户扩展属性表 (Key-Value 列存储模式)
|
||||
"""
|
||||
|
||||
__tablename__ = "sys_user_attribute"
|
||||
|
||||
user_id = db.Column(
|
||||
db.String(36),
|
||||
db.ForeignKey("sys_user.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
comment="用户ID",
|
||||
)
|
||||
attr_group = db.Column(
|
||||
db.String(64), nullable=False, index=True, comment="属性分组(如: erp, custom)"
|
||||
)
|
||||
attr_key = db.Column(db.String(128), nullable=False, comment="属性键")
|
||||
attr_value = db.Column(db.Text, nullable=True, comment="属性值")
|
||||
attr_type = db.Column(
|
||||
db.String(32),
|
||||
nullable=False,
|
||||
default="string",
|
||||
comment="值类型(string/int/float/bool/json/encrypted)",
|
||||
)
|
||||
description = db.Column(db.String(255), nullable=True, comment="属性描述")
|
||||
sort = db.Column(db.Integer, nullable=False, default=0, comment="排序")
|
||||
|
||||
# 关系
|
||||
user = db.relationship("User", back_populates="user_attributes")
|
||||
|
||||
# 联合唯一索引:一个用户的同一分组下不能有重复的键
|
||||
__table_args__ = (
|
||||
db.Index("idx_user_group_key", "user_id", "attr_group", "attr_key"),
|
||||
db.UniqueConstraint(
|
||||
"user_id", "attr_group", "attr_key", name="uk_user_group_key"
|
||||
),
|
||||
)
|
||||
|
||||
def get_typed_value(self):
|
||||
"""
|
||||
根据 attr_type 返回类型化的值
|
||||
"""
|
||||
if self.attr_value is None:
|
||||
return None
|
||||
|
||||
if self.attr_type == "int":
|
||||
try:
|
||||
return int(self.attr_value)
|
||||
except (ValueError, TypeError):
|
||||
return None
|
||||
elif self.attr_type == "float":
|
||||
try:
|
||||
return float(self.attr_value)
|
||||
except (ValueError, TypeError):
|
||||
return None
|
||||
elif self.attr_type == "bool":
|
||||
return self.attr_value.lower() in ("true", "1", "yes", "on")
|
||||
elif self.attr_type == "json":
|
||||
import json
|
||||
|
||||
try:
|
||||
return json.loads(self.attr_value)
|
||||
except (ValueError, TypeError):
|
||||
return None
|
||||
elif self.attr_type == "encrypted":
|
||||
# 加密字段,返回时不解密(需要时在业务层处理)
|
||||
return "******"
|
||||
else: # string
|
||||
return self.attr_value
|
||||
|
||||
def set_typed_value(self, value):
|
||||
"""
|
||||
根据 attr_type 设置类型化的值
|
||||
"""
|
||||
if value is None:
|
||||
self.attr_value = None
|
||||
return
|
||||
|
||||
if self.attr_type == "json":
|
||||
import json
|
||||
|
||||
self.attr_value = json.dumps(value, ensure_ascii=False)
|
||||
elif self.attr_type == "bool":
|
||||
self.attr_value = "true" if value else "false"
|
||||
else:
|
||||
self.attr_value = str(value)
|
||||
|
||||
|
||||
class SysUserAttributeSchema(BaseSchema):
|
||||
"""
|
||||
用户扩展属性 Schema
|
||||
"""
|
||||
|
||||
id = String()
|
||||
user_id = String(data_key="userId")
|
||||
attr_group = String(data_key="attrGroup")
|
||||
attr_key = String(data_key="attrKey")
|
||||
attr_value = String(data_key="attrValue")
|
||||
attr_type = String(data_key="attrType")
|
||||
description = String()
|
||||
sort = Integer()
|
||||
@ -0,0 +1,6 @@
|
||||
from .upload import bp as upload_bp
|
||||
from .file_access import bp as file_access_bp
|
||||
|
||||
def register_common_bp(app):
|
||||
app.register_blueprint(upload_bp)
|
||||
app.register_blueprint(file_access_bp)
|
||||
@ -0,0 +1,2 @@
|
||||
from .upload import *
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
|
||||
def init_services(app) -> None:
|
||||
"""初始化Services"""
|
||||
# 初始化文件系统配置
|
||||
from iti.applications.service.sys.sys_file_config import init_app as init_file_config
|
||||
init_file_config(app)
|
||||
|
||||
# 初始化文件目录
|
||||
from iti.applications.service.sys.sys_file_directory import init_app as init_file_directory
|
||||
init_file_directory(app)
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,42 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0c4f1f46e5ea
|
||||
Revises: c46167ccbf4d
|
||||
Create Date: 2025-10-21 19:31:35.196178
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0c4f1f46e5ea'
|
||||
down_revision = 'c46167ccbf4d'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('sys_dept',
|
||||
sa.Column('name', sa.String(length=255), nullable=False, comment='部门名称'),
|
||||
sa.Column('parent_id', sa.String(length=36), nullable=False, comment='父部门ID'),
|
||||
sa.Column('desc', sa.Text(), nullable=True, comment='部门描述'),
|
||||
sa.Column('sort', sa.Integer(), nullable=False, comment='排序'),
|
||||
sa.Column('leader_id', sa.String(length=36), nullable=True, comment='负责人ID'),
|
||||
sa.Column('status', sa.Enum('enabled', 'disabled', name='statusenum'), nullable=False, comment='状态'),
|
||||
sa.Column('id', sa.String(length=36), nullable=False, comment='标识'),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False, comment='创建时间'),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=False, comment='更新时间'),
|
||||
sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_sys_dept')),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_general_ci'
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('sys_dept')
|
||||
# ### end Alembic commands ###
|
||||
@ -1,32 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 3a1d8599c640
|
||||
Revises: 70dac20262ef
|
||||
Create Date: 2025-10-24 15:28:07.476192
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3a1d8599c640'
|
||||
down_revision = '70dac20262ef'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_config', schema=None) as batch_op:
|
||||
batch_op.drop_column('json_value')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_config', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('json_value', sa.TEXT(), nullable=True))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@ -1,36 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 3b3e7f8dd32f
|
||||
Revises: e0addf88b922
|
||||
Create Date: 2025-10-22 23:47:18.790303
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3b3e7f8dd32f'
|
||||
down_revision = 'e0addf88b922'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_dept', schema=None) as batch_op:
|
||||
batch_op.alter_column('parent_id',
|
||||
existing_type=sa.VARCHAR(length=36),
|
||||
nullable=True)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_dept', schema=None) as batch_op:
|
||||
batch_op.alter_column('parent_id',
|
||||
existing_type=sa.VARCHAR(length=36),
|
||||
nullable=False)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@ -1,88 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 5409f28814f9
|
||||
Revises: 83b464bfff02
|
||||
Create Date: 2025-10-30 22:31:50.159590
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '5409f28814f9'
|
||||
down_revision = '83b464bfff02'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('sys_file_directory',
|
||||
sa.Column('name', sa.String(length=255), nullable=False, comment='目录名称'),
|
||||
sa.Column('path', sa.String(length=1024), nullable=False, comment='完整路径'),
|
||||
sa.Column('parent_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('level', sa.Integer(), nullable=True, comment='层级'),
|
||||
sa.Column('sort', sa.Integer(), nullable=True, comment='排序'),
|
||||
sa.Column('icon', sa.String(length=128), nullable=True, comment='目录图标'),
|
||||
sa.Column('color', sa.String(length=32), nullable=True, comment='颜色标记'),
|
||||
sa.Column('description', sa.Text(), nullable=True, comment='目录描述'),
|
||||
sa.Column('default_storage_type', sa.String(length=32), nullable=True, comment='默认存储类型'),
|
||||
sa.Column('status', sa.Enum('enabled', 'disabled', name='statusenum'), nullable=False, comment='状态'),
|
||||
sa.Column('id', sa.String(length=36), nullable=False, comment='标识'),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False, comment='创建时间'),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=False, comment='更新时间'),
|
||||
sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'),
|
||||
sa.ForeignKeyConstraint(['parent_id'], ['sys_file_directory.id'], name=op.f('fk_sys_file_directory_parent_id_sys_file_directory'), ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_sys_file_directory')),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_general_ci'
|
||||
)
|
||||
with op.batch_alter_table('sys_file_directory', schema=None) as batch_op:
|
||||
batch_op.create_index(batch_op.f('ix_sys_file_directory_path'), ['path'], unique=False)
|
||||
|
||||
op.create_table('sys_file',
|
||||
sa.Column('filename', sa.String(length=255), nullable=False, comment='原始文件名'),
|
||||
sa.Column('file_key', sa.String(length=512), nullable=False, comment='存储路径'),
|
||||
sa.Column('file_hash', sa.String(length=64), nullable=True, comment='文件哈希'),
|
||||
sa.Column('mime_type', sa.String(length=128), nullable=True, comment='MIME类型'),
|
||||
sa.Column('file_size', sa.BigInteger(), nullable=False, comment='文件大小(字节)'),
|
||||
sa.Column('extension', sa.String(length=32), nullable=True, comment='文件扩展名'),
|
||||
sa.Column('storage_type', sa.Enum('local', 'aliyun_oss', 'tencent_cos', 'qiniu_kodo', 'huawei_obs', 'aws_s3', 'minio', name='storagetypeenum'), nullable=False, comment='存储类型'),
|
||||
sa.Column('storage_bucket', sa.String(length=128), nullable=True, comment='存储桶'),
|
||||
sa.Column('storage_region', sa.String(length=64), nullable=True, comment='存储区域'),
|
||||
sa.Column('storage_endpoint', sa.String(length=255), nullable=True, comment='存储端点'),
|
||||
sa.Column('storage_meta', sa.JSON(), nullable=True, comment='存储元信息'),
|
||||
sa.Column('directory_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('metadata', sa.JSON(), nullable=True, comment='扩展元数据'),
|
||||
sa.Column('status', sa.Enum('enabled', 'disabled', name='statusenum'), nullable=False, comment='状态'),
|
||||
sa.Column('id', sa.String(length=36), nullable=False, comment='标识'),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False, comment='创建时间'),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=False, comment='更新时间'),
|
||||
sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'),
|
||||
sa.ForeignKeyConstraint(['directory_id'], ['sys_file_directory.id'], name=op.f('fk_sys_file_directory_id_sys_file_directory'), ondelete='SET NULL'),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_sys_file')),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_general_ci'
|
||||
)
|
||||
with op.batch_alter_table('sys_file', schema=None) as batch_op:
|
||||
batch_op.create_index(batch_op.f('ix_sys_file_directory_id'), ['directory_id'], unique=False)
|
||||
batch_op.create_index(batch_op.f('ix_sys_file_file_hash'), ['file_hash'], unique=False)
|
||||
batch_op.create_index(batch_op.f('ix_sys_file_file_key'), ['file_key'], unique=True)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_file', schema=None) as batch_op:
|
||||
batch_op.drop_index(batch_op.f('ix_sys_file_file_key'))
|
||||
batch_op.drop_index(batch_op.f('ix_sys_file_file_hash'))
|
||||
batch_op.drop_index(batch_op.f('ix_sys_file_directory_id'))
|
||||
|
||||
op.drop_table('sys_file')
|
||||
with op.batch_alter_table('sys_file_directory', schema=None) as batch_op:
|
||||
batch_op.drop_index(batch_op.f('ix_sys_file_directory_path'))
|
||||
|
||||
op.drop_table('sys_file_directory')
|
||||
# ### end Alembic commands ###
|
||||
@ -1,32 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 5c84e633f254
|
||||
Revises: 5eb37be53e1c
|
||||
Create Date: 2025-10-21 16:32:48.572116
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '5c84e633f254'
|
||||
down_revision = '5eb37be53e1c'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_user', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('desc', sa.Text(), nullable=True, comment='描述'))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_user', schema=None) as batch_op:
|
||||
batch_op.drop_column('desc')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@ -1,46 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 5eb37be53e1c
|
||||
Revises: fffd191071bc
|
||||
Create Date: 2025-10-20 13:47:47.890488
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '5eb37be53e1c'
|
||||
down_revision = 'fffd191071bc'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_menu', schema=None) as batch_op:
|
||||
batch_op.alter_column('component',
|
||||
existing_type=sa.VARCHAR(length=255),
|
||||
nullable=True)
|
||||
batch_op.alter_column('parent_id',
|
||||
existing_type=sa.VARCHAR(length=36),
|
||||
nullable=True)
|
||||
batch_op.create_unique_constraint(batch_op.f('uq_sys_menu_name'), ['name'])
|
||||
batch_op.create_unique_constraint(batch_op.f('uq_sys_menu_path'), ['path'])
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_menu', schema=None) as batch_op:
|
||||
batch_op.drop_constraint(batch_op.f('uq_sys_menu_path'), type_='unique')
|
||||
batch_op.drop_constraint(batch_op.f('uq_sys_menu_name'), type_='unique')
|
||||
batch_op.alter_column('parent_id',
|
||||
existing_type=sa.VARCHAR(length=36),
|
||||
nullable=False)
|
||||
batch_op.alter_column('component',
|
||||
existing_type=sa.VARCHAR(length=255),
|
||||
nullable=False)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@ -1,32 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 70dac20262ef
|
||||
Revises: 3b3e7f8dd32f
|
||||
Create Date: 2025-10-23 10:05:55.795788
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '70dac20262ef'
|
||||
down_revision = '3b3e7f8dd32f'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('sys_role_menu',
|
||||
sa.Column('role_id', sa.String(length=36), nullable=False, comment='角色ID'),
|
||||
sa.Column('menu_id', sa.String(length=36), nullable=False, comment='菜单ID'),
|
||||
sa.PrimaryKeyConstraint('role_id', 'menu_id', name=op.f('pk_sys_role_menu'))
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('sys_role_menu')
|
||||
# ### end Alembic commands ###
|
||||
@ -1,50 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 83b464bfff02
|
||||
Revises: 3a1d8599c640
|
||||
Create Date: 2025-10-27 20:02:41.075217
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '83b464bfff02'
|
||||
down_revision = '3a1d8599c640'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_log', schema=None) as batch_op:
|
||||
batch_op.alter_column('type',
|
||||
existing_type=sa.VARCHAR(length=64),
|
||||
type_=sa.Enum('SYSTEM', 'AUTH', 'OPERATION', 'AUDIT', 'SECURITY', 'JOB', 'API', 'DB', 'PAYMENT', 'MESSAGE', 'OSS', 'OTHER', name='logtype'),
|
||||
nullable=False)
|
||||
batch_op.drop_index(batch_op.f('ix_sys_log_type'))
|
||||
|
||||
with op.batch_alter_table('sys_user', schema=None) as batch_op:
|
||||
batch_op.alter_column('realname',
|
||||
existing_type=sa.VARCHAR(length=32),
|
||||
nullable=True)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_user', schema=None) as batch_op:
|
||||
batch_op.alter_column('realname',
|
||||
existing_type=sa.VARCHAR(length=32),
|
||||
nullable=False)
|
||||
|
||||
with op.batch_alter_table('sys_log', schema=None) as batch_op:
|
||||
batch_op.create_index(batch_op.f('ix_sys_log_type'), ['type'], unique=False)
|
||||
batch_op.alter_column('type',
|
||||
existing_type=sa.Enum('SYSTEM', 'AUTH', 'OPERATION', 'AUDIT', 'SECURITY', 'JOB', 'API', 'DB', 'PAYMENT', 'MESSAGE', 'OSS', 'OTHER', name='logtype'),
|
||||
type_=sa.VARCHAR(length=64),
|
||||
nullable=True)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@ -1,40 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: bfa0b0c7c62f
|
||||
Revises: f02e03313631
|
||||
Create Date: 2025-10-30 23:31:12.508052
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import sqlite
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'bfa0b0c7c62f'
|
||||
down_revision = 'f02e03313631'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_file', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('storage_info', sa.JSON(), nullable=True, comment='存储信息(bucket/region/endpoint/meta等)'))
|
||||
batch_op.drop_column('storage_meta')
|
||||
batch_op.drop_column('storage_bucket')
|
||||
batch_op.drop_column('storage_region')
|
||||
batch_op.drop_column('storage_endpoint')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_file', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('storage_endpoint', sa.VARCHAR(length=255), nullable=True))
|
||||
batch_op.add_column(sa.Column('storage_region', sa.VARCHAR(length=64), nullable=True))
|
||||
batch_op.add_column(sa.Column('storage_bucket', sa.VARCHAR(length=128), nullable=True))
|
||||
batch_op.add_column(sa.Column('storage_meta', sqlite.JSON(), nullable=True))
|
||||
batch_op.drop_column('storage_info')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@ -1,170 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: c46167ccbf4d
|
||||
Revises: 5c84e633f254
|
||||
Create Date: 2025-10-21 19:31:04.980171
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c46167ccbf4d'
|
||||
down_revision = '5c84e633f254'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_config', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'))
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
batch_op.alter_column('updated_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
|
||||
with op.batch_alter_table('sys_dept', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'))
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
batch_op.alter_column('updated_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
|
||||
with op.batch_alter_table('sys_dict_data', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'))
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
batch_op.alter_column('updated_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
|
||||
with op.batch_alter_table('sys_dict_type', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'))
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
batch_op.alter_column('updated_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
|
||||
with op.batch_alter_table('sys_log', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'))
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
batch_op.alter_column('updated_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
|
||||
with op.batch_alter_table('sys_menu', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'))
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
batch_op.alter_column('updated_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
|
||||
with op.batch_alter_table('sys_role', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'))
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
batch_op.alter_column('updated_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
|
||||
with op.batch_alter_table('sys_user', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'))
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
batch_op.alter_column('updated_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_user', schema=None) as batch_op:
|
||||
batch_op.alter_column('updated_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
batch_op.drop_column('remark')
|
||||
|
||||
with op.batch_alter_table('sys_role', schema=None) as batch_op:
|
||||
batch_op.alter_column('updated_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
batch_op.drop_column('remark')
|
||||
|
||||
with op.batch_alter_table('sys_menu', schema=None) as batch_op:
|
||||
batch_op.alter_column('updated_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
batch_op.drop_column('remark')
|
||||
|
||||
with op.batch_alter_table('sys_log', schema=None) as batch_op:
|
||||
batch_op.alter_column('updated_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
batch_op.drop_column('remark')
|
||||
|
||||
with op.batch_alter_table('sys_dict_type', schema=None) as batch_op:
|
||||
batch_op.alter_column('updated_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
batch_op.drop_column('remark')
|
||||
|
||||
with op.batch_alter_table('sys_dict_data', schema=None) as batch_op:
|
||||
batch_op.alter_column('updated_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
batch_op.drop_column('remark')
|
||||
|
||||
with op.batch_alter_table('sys_dept', schema=None) as batch_op:
|
||||
batch_op.alter_column('updated_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
batch_op.drop_column('remark')
|
||||
|
||||
with op.batch_alter_table('sys_config', schema=None) as batch_op:
|
||||
batch_op.alter_column('updated_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
batch_op.drop_column('remark')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@ -1,38 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: e0addf88b922
|
||||
Revises: eba4a4c12851
|
||||
Create Date: 2025-10-22 01:09:43.193921
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'e0addf88b922'
|
||||
down_revision = 'eba4a4c12851'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_menu', schema=None) as batch_op:
|
||||
batch_op.alter_column('path',
|
||||
existing_type=sa.VARCHAR(length=255),
|
||||
nullable=True)
|
||||
batch_op.drop_constraint(batch_op.f('uq_sys_menu_path'), type_='unique')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_menu', schema=None) as batch_op:
|
||||
batch_op.create_unique_constraint(batch_op.f('uq_sys_menu_path'), ['path'])
|
||||
batch_op.alter_column('path',
|
||||
existing_type=sa.VARCHAR(length=255),
|
||||
nullable=False)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@ -1,32 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: eba4a4c12851
|
||||
Revises: 0c4f1f46e5ea
|
||||
Create Date: 2025-10-21 23:01:50.526401
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'eba4a4c12851'
|
||||
down_revision = '0c4f1f46e5ea'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_menu', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('auth_code', sa.String(length=128), nullable=True, comment='权限编码'))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_menu', schema=None) as batch_op:
|
||||
batch_op.drop_column('auth_code')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@ -1,38 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: f02e03313631
|
||||
Revises: 5409f28814f9
|
||||
Create Date: 2025-10-30 22:36:59.048268
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'f02e03313631'
|
||||
down_revision = '5409f28814f9'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_file', schema=None) as batch_op:
|
||||
batch_op.drop_constraint(batch_op.f('fk_sys_file_directory_id_sys_file_directory'), type_='foreignkey')
|
||||
|
||||
with op.batch_alter_table('sys_file_directory', schema=None) as batch_op:
|
||||
batch_op.drop_constraint(batch_op.f('fk_sys_file_directory_parent_id_sys_file_directory'), type_='foreignkey')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sys_file_directory', schema=None) as batch_op:
|
||||
batch_op.create_foreign_key(batch_op.f('fk_sys_file_directory_parent_id_sys_file_directory'), 'sys_file_directory', ['parent_id'], ['id'], ondelete='CASCADE')
|
||||
|
||||
with op.batch_alter_table('sys_file', schema=None) as batch_op:
|
||||
batch_op.create_foreign_key(batch_op.f('fk_sys_file_directory_id_sys_file_directory'), 'sys_file_directory', ['directory_id'], ['id'], ondelete='SET NULL')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@ -1,149 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: f9f008bd64bf
|
||||
Revises:
|
||||
Create Date: 2025-10-19 11:02:21.153893
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'f9f008bd64bf'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('sys_config',
|
||||
sa.Column('type', sa.String(length=64), nullable=False, comment='配置类型'),
|
||||
sa.Column('name', sa.String(length=255), nullable=False, comment='配置名称'),
|
||||
sa.Column('code', sa.String(length=128), nullable=False, comment='配置编码'),
|
||||
sa.Column('value', sa.Text(), nullable=True, comment='配置值'),
|
||||
sa.Column('json_value', sa.Text(), nullable=True, comment='配置值(JSON格式)'),
|
||||
sa.Column('desc', sa.Text(), nullable=True, comment='配置描述'),
|
||||
sa.Column('sort', sa.Integer(), nullable=False, comment='排序'),
|
||||
sa.Column('status', sa.Enum('enabled', 'disabled', name='statusenum'), nullable=False, comment='状态'),
|
||||
sa.Column('id', sa.String(length=36), nullable=False, comment='标识'),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_sys_config'))
|
||||
)
|
||||
op.create_table('sys_dept',
|
||||
sa.Column('name', sa.String(length=255), nullable=False, comment='部门名称'),
|
||||
sa.Column('parent_id', sa.String(length=36), nullable=False, comment='父部门ID'),
|
||||
sa.Column('desc', sa.Text(), nullable=True, comment='部门描述'),
|
||||
sa.Column('sort', sa.Integer(), nullable=False, comment='排序'),
|
||||
sa.Column('leader_id', sa.String(length=36), nullable=True, comment='负责人ID'),
|
||||
sa.Column('status', sa.Enum('enabled', 'disabled', name='statusenum'), nullable=False, comment='状态'),
|
||||
sa.Column('id', sa.String(length=36), nullable=False, comment='标识'),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_sys_dept'))
|
||||
)
|
||||
op.create_table('sys_dict_data',
|
||||
sa.Column('type_code', sa.String(length=36), nullable=False, comment='类型编码'),
|
||||
sa.Column('label', sa.String(length=255), nullable=False, comment='数据标签'),
|
||||
sa.Column('code', sa.String(length=128), nullable=False, comment='数据编码'),
|
||||
sa.Column('value', sa.Text(), nullable=True, comment='数据值'),
|
||||
sa.Column('desc', sa.Text(), nullable=True, comment='数据描述'),
|
||||
sa.Column('sort', sa.Integer(), nullable=False, comment='排序'),
|
||||
sa.Column('status', sa.Enum('enabled', 'disabled', name='statusenum'), nullable=False, comment='状态'),
|
||||
sa.Column('id', sa.String(length=36), nullable=False, comment='标识'),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_sys_dict_data'))
|
||||
)
|
||||
op.create_table('sys_dict_type',
|
||||
sa.Column('type_name', sa.String(length=255), nullable=False, comment='类型名称'),
|
||||
sa.Column('type_code', sa.String(length=128), nullable=False, comment='类型编码'),
|
||||
sa.Column('desc', sa.Text(), nullable=True, comment='类型描述'),
|
||||
sa.Column('sort', sa.Integer(), nullable=False, comment='排序'),
|
||||
sa.Column('status', sa.Enum('enabled', 'disabled', name='statusenum'), nullable=False, comment='状态'),
|
||||
sa.Column('id', sa.String(length=36), nullable=False, comment='标识'),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_sys_dict_type')),
|
||||
sa.UniqueConstraint('type_code', name=op.f('uq_sys_dict_type_type_code'))
|
||||
)
|
||||
op.create_table('sys_log',
|
||||
sa.Column('name', sa.String(length=100), nullable=True, comment='操作名称'),
|
||||
sa.Column('method', sa.String(length=10), nullable=True, comment='请求方法'),
|
||||
sa.Column('user_id', sa.String(length=36), nullable=True, comment='用户ID'),
|
||||
sa.Column('path', sa.String(length=255), nullable=True, comment='请求路径'),
|
||||
sa.Column('ip', sa.String(length=255), nullable=True, comment='IP地址'),
|
||||
sa.Column('user_agent', sa.Text(), nullable=True, comment='用户代理'),
|
||||
sa.Column('headers', sa.Text(), nullable=True, comment='请求头'),
|
||||
sa.Column('query_params', sa.Text(), nullable=True, comment='请求参数'),
|
||||
sa.Column('body_params', sa.Text(), nullable=True, comment='请求体参数'),
|
||||
sa.Column('execution_time', sa.Float(), nullable=True, comment='执行时间(毫秒)'),
|
||||
sa.Column('response', sa.Text(), nullable=True, comment='响应结果'),
|
||||
sa.Column('exception', sa.Text(), nullable=True, comment='异常信息'),
|
||||
sa.Column('success', sa.Boolean(), nullable=True, comment='是否成功'),
|
||||
sa.Column('desc', sa.Text(), nullable=True, comment='描述'),
|
||||
sa.Column('type', sa.String(length=64), nullable=True, comment='日志类型'),
|
||||
sa.Column('id', sa.String(length=36), nullable=False, comment='标识'),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_sys_log'))
|
||||
)
|
||||
with op.batch_alter_table('sys_log', schema=None) as batch_op:
|
||||
batch_op.create_index(batch_op.f('ix_sys_log_type'), ['type'], unique=False)
|
||||
|
||||
op.create_table('sys_role',
|
||||
sa.Column('name', sa.String(length=64), nullable=False, comment='名称'),
|
||||
sa.Column('code', sa.String(length=64), nullable=False, comment='编码'),
|
||||
sa.Column('desc', sa.Text(), nullable=True, comment='描述'),
|
||||
sa.Column('sort', sa.Integer(), nullable=False, comment='排序'),
|
||||
sa.Column('status', sa.Enum('enabled', 'disabled', name='statusenum'), nullable=False, comment='状态'),
|
||||
sa.Column('id', sa.String(length=36), nullable=False, comment='标识'),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_sys_role')),
|
||||
sa.UniqueConstraint('code', name=op.f('uq_sys_role_code'))
|
||||
)
|
||||
op.create_table('sys_user',
|
||||
sa.Column('username', sa.String(length=64), nullable=False, comment='用户名'),
|
||||
sa.Column('phone', sa.String(length=13), nullable=True, comment='手机号'),
|
||||
sa.Column('email', sa.String(length=255), nullable=True, comment='邮箱'),
|
||||
sa.Column('password', sa.String(length=255), nullable=False, comment='密码'),
|
||||
sa.Column('realname', sa.String(length=32), nullable=False, comment='真实姓名'),
|
||||
sa.Column('avatar', sa.String(length=255), nullable=True, comment='头像'),
|
||||
sa.Column('gender', sa.Enum('male', 'female', 'secure', name='genderenum'), nullable=False, comment='性别'),
|
||||
sa.Column('status', sa.Enum('enabled', 'disabled', name='statusenum'), nullable=False, comment='状态'),
|
||||
sa.Column('id', sa.String(length=36), nullable=False, comment='标识'),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_sys_user'))
|
||||
)
|
||||
op.create_table('sys_user_dept',
|
||||
sa.Column('user_id', sa.String(length=36), nullable=False, comment='用户ID'),
|
||||
sa.Column('dept_id', sa.String(length=36), nullable=False, comment='部门ID'),
|
||||
sa.PrimaryKeyConstraint('user_id', 'dept_id', name=op.f('pk_sys_user_dept'))
|
||||
)
|
||||
op.create_table('sys_user_role',
|
||||
sa.Column('user_id', sa.String(length=36), nullable=False, comment='用户ID'),
|
||||
sa.Column('role_id', sa.String(length=36), nullable=False, comment='角色ID'),
|
||||
sa.PrimaryKeyConstraint('user_id', 'role_id', name=op.f('pk_sys_user_role'))
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('sys_user_role')
|
||||
op.drop_table('sys_user_dept')
|
||||
op.drop_table('sys_user')
|
||||
op.drop_table('sys_role')
|
||||
with op.batch_alter_table('sys_log', schema=None) as batch_op:
|
||||
batch_op.drop_index(batch_op.f('ix_sys_log_type'))
|
||||
|
||||
op.drop_table('sys_log')
|
||||
op.drop_table('sys_dict_type')
|
||||
op.drop_table('sys_dict_data')
|
||||
op.drop_table('sys_dept')
|
||||
op.drop_table('sys_config')
|
||||
# ### end Alembic commands ###
|
||||
@ -1,42 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: fffd191071bc
|
||||
Revises: f9f008bd64bf
|
||||
Create Date: 2025-10-20 11:27:19.426979
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'fffd191071bc'
|
||||
down_revision = 'f9f008bd64bf'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('sys_menu',
|
||||
sa.Column('name', sa.String(length=255), nullable=False, comment='菜单名称'),
|
||||
sa.Column('type', sa.Enum('catalog', 'menu', 'button', 'embedded', 'link', name='menutypeenum'), nullable=False, comment='菜单类型'),
|
||||
sa.Column('path', sa.String(length=255), nullable=False, comment='菜单路径'),
|
||||
sa.Column('component', sa.String(length=255), nullable=False, comment='菜单组件'),
|
||||
sa.Column('redirect', sa.String(length=255), nullable=True, comment='菜单重定向'),
|
||||
sa.Column('sort', sa.Integer(), nullable=False, comment='排序'),
|
||||
sa.Column('meta', sa.JSON(), nullable=True, comment='菜单元数据'),
|
||||
sa.Column('status', sa.Enum('enabled', 'disabled', name='statusenum'), nullable=False, comment='状态'),
|
||||
sa.Column('parent_id', sa.String(length=36), nullable=False, comment='父菜单ID'),
|
||||
sa.Column('id', sa.String(length=36), nullable=False, comment='标识'),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_sys_menu'))
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('sys_menu')
|
||||
# ### end Alembic commands ###
|
||||
Loading…
Reference in New Issue