"""init tables Revision ID: 9c178034aad7 Revises: Create Date: 2026-05-09 15:06:03.431213 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. revision: str = '9c178034aad7' 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('ai_agent', sa.Column('application_id', sa.String(length=21), nullable=True, comment='所属应用ID(逻辑外键关联core_application)'), sa.Column('is_global', sa.Boolean(), nullable=True, comment='是否在子应用中可见'), sa.Column('name', sa.String(length=100), nullable=False, comment='智能体名称'), sa.Column('code', sa.String(length=100), nullable=False, comment='智能体编码'), sa.Column('description', sa.Text(), nullable=True, comment='智能体描述'), sa.Column('avatar', sa.String(length=500), nullable=True, comment='头像 URL'), sa.Column('mode', sa.String(length=20), nullable=True, comment='运行模式: autonomous/dialog_flow'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: draft/published/disabled'), sa.Column('persona', sa.JSON(), nullable=True, comment='人设配置'), sa.Column('system_prompt', sa.Text(), nullable=True, comment='系统提示词'), sa.Column('model_id', sa.String(length=21), nullable=True, comment='默认模型ID(逻辑外键关联ai_llm_model)'), sa.Column('temperature', sa.Float(), nullable=True, comment='温度参数(0-2)'), sa.Column('top_p', sa.Float(), nullable=True, comment='top_p 参数'), sa.Column('max_tokens', sa.Integer(), nullable=True, comment='最大输出 Token'), sa.Column('max_iterations', sa.Integer(), nullable=True, comment='最大推理轮数'), sa.Column('welcome_message', sa.Text(), nullable=True, comment='开场白'), sa.Column('suggested_questions', sa.JSON(), nullable=True, comment='推荐问题列表'), sa.Column('workflow_id', sa.String(length=21), nullable=True, comment='关联工作流ID(逻辑外键关联ai_workflow)'), sa.Column('enable_memory', sa.Boolean(), nullable=True, comment='是否启用对话记忆'), sa.Column('memory_window', sa.Integer(), nullable=True, comment='记忆窗口大小(最近 N 轮对话)'), sa.Column('enable_streaming', sa.Boolean(), nullable=True, comment='是否启用流式输出(自主规划模式)'), sa.Column('knowledge_base_ids', sa.JSON(), nullable=True, comment='关联的知识库ID列表'), sa.Column('knowledge_config', sa.JSON(), nullable=True, comment='知识库检索配置(top_k/score_threshold/retrieval_mode等)'), sa.Column('is_public', sa.Boolean(), nullable=True, comment='是否公开'), sa.Column('conversation_count', sa.Integer(), nullable=True, comment='对话数量'), sa.Column('message_count', sa.Integer(), nullable=True, comment='消息数量'), sa.Column('total_tokens', sa.Integer(), nullable=True, comment='总 Token 消耗'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('code') ) op.create_index(op.f('ix_ai_agent_application_id'), 'ai_agent', ['application_id'], unique=False) op.create_index(op.f('ix_ai_agent_is_deleted'), 'ai_agent', ['is_deleted'], unique=False) op.create_index(op.f('ix_ai_agent_model_id'), 'ai_agent', ['model_id'], unique=False) op.create_index(op.f('ix_ai_agent_sys_create_datetime'), 'ai_agent', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_ai_agent_sys_creator_id'), 'ai_agent', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_ai_agent_sys_dept_id'), 'ai_agent', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_ai_agent_sys_update_datetime'), 'ai_agent', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_ai_agent_workflow_id'), 'ai_agent', ['workflow_id'], unique=False) op.create_table('ai_agent_conversation', sa.Column('agent_id', sa.String(length=21), nullable=False, comment='智能体ID(逻辑外键关联ai_agent)'), sa.Column('user_id', sa.String(length=21), nullable=True, comment='用户ID(逻辑外键关联core_user)'), sa.Column('title', sa.String(length=200), nullable=True, comment='对话标题'), sa.Column('summary', sa.Text(), nullable=True, comment='对话摘要'), sa.Column('workflow_run_id', sa.String(length=21), nullable=True, comment='工作流运行实例ID(逻辑外键关联ai_workflow_run)'), sa.Column('waiting_node_id', sa.String(length=100), nullable=True, comment='等待输入的节点 ID'), sa.Column('extra_data', sa.JSON(), nullable=True, comment='元数据'), sa.Column('message_count', sa.Integer(), nullable=True, comment='消息数量'), sa.Column('total_tokens', sa.Integer(), nullable=True, comment='总 Token 消耗'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_ai_agent_conversation_agent_id'), 'ai_agent_conversation', ['agent_id'], unique=False) op.create_index('ix_ai_agent_conversation_agent_user', 'ai_agent_conversation', ['agent_id', 'user_id'], unique=False) op.create_index(op.f('ix_ai_agent_conversation_is_deleted'), 'ai_agent_conversation', ['is_deleted'], unique=False) op.create_index(op.f('ix_ai_agent_conversation_sys_create_datetime'), 'ai_agent_conversation', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_ai_agent_conversation_sys_creator_id'), 'ai_agent_conversation', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_ai_agent_conversation_sys_dept_id'), 'ai_agent_conversation', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_ai_agent_conversation_sys_update_datetime'), 'ai_agent_conversation', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_ai_agent_conversation_user_id'), 'ai_agent_conversation', ['user_id'], unique=False) op.create_table('ai_agent_message', sa.Column('conversation_id', sa.String(length=21), nullable=False, comment='对话ID(逻辑外键关联ai_agent_conversation)'), sa.Column('role', sa.String(length=20), nullable=False, comment='角色: user/assistant/tool/system'), sa.Column('content', sa.Text(), nullable=True, comment='消息内容'), sa.Column('attachments', sa.JSON(), nullable=True, comment='附件列表 [{id, type, name, url, mime_type, size}]'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: pending/completed/failed'), sa.Column('reasoning_steps', sa.JSON(), nullable=True, comment='推理步骤'), sa.Column('tool_calls', sa.JSON(), nullable=True, comment='工具调用记录'), sa.Column('prompt_tokens', sa.Integer(), nullable=True, comment='提示 Token'), sa.Column('completion_tokens', sa.Integer(), nullable=True, comment='生成 Token'), sa.Column('total_tokens', sa.Integer(), nullable=True, comment='总 Token'), sa.Column('elapsed_time', sa.Integer(), nullable=True, comment='耗时(毫秒)'), sa.Column('error_message', sa.Text(), nullable=True, comment='错误信息'), sa.Column('feedback', sa.String(length=20), nullable=True, comment='用户反馈(like/dislike)'), sa.Column('feedback_content', sa.Text(), nullable=True, comment='反馈内容'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_ai_agent_message_conversation_id'), 'ai_agent_message', ['conversation_id'], unique=False) op.create_index('ix_ai_agent_message_conversation_role', 'ai_agent_message', ['conversation_id', 'role'], unique=False) op.create_index(op.f('ix_ai_agent_message_is_deleted'), 'ai_agent_message', ['is_deleted'], unique=False) op.create_index(op.f('ix_ai_agent_message_sys_create_datetime'), 'ai_agent_message', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_ai_agent_message_sys_creator_id'), 'ai_agent_message', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_ai_agent_message_sys_dept_id'), 'ai_agent_message', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_ai_agent_message_sys_update_datetime'), 'ai_agent_message', ['sys_update_datetime'], unique=False) op.create_table('ai_app', sa.Column('name', sa.String(length=100), nullable=False, comment='应用名称'), sa.Column('code', sa.String(length=100), nullable=False, comment='应用编码'), sa.Column('description', sa.Text(), nullable=True, comment='应用描述'), sa.Column('icon', sa.String(length=100), nullable=True, comment='应用图标'), sa.Column('app_type', sa.String(length=20), nullable=True, comment='应用类型: chat/completion/workflow/agent'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: draft/published/disabled'), sa.Column('model_id', sa.String(length=21), nullable=True, comment='默认模型ID(逻辑外键关联ai_llm_model)'), sa.Column('system_prompt', sa.Text(), nullable=True, comment='系统提示词'), sa.Column('temperature', sa.Float(), nullable=True, comment='温度参数'), sa.Column('top_p', sa.Float(), nullable=True, comment='top_p 参数'), sa.Column('max_tokens', sa.Integer(), nullable=True, comment='最大输出 Token'), sa.Column('workflow_definition', sa.JSON(), nullable=True, comment='工作流定义'), sa.Column('opening_statement', sa.Text(), nullable=True, comment='开场白'), sa.Column('suggested_questions', sa.JSON(), nullable=True, comment='建议问题列表'), sa.Column('is_public', sa.Boolean(), nullable=True, comment='是否公开'), sa.Column('conversation_count', sa.Integer(), nullable=True, comment='对话数量'), sa.Column('message_count', sa.Integer(), nullable=True, comment='消息数量'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('code') ) op.create_index(op.f('ix_ai_app_is_deleted'), 'ai_app', ['is_deleted'], unique=False) op.create_index(op.f('ix_ai_app_model_id'), 'ai_app', ['model_id'], unique=False) op.create_index(op.f('ix_ai_app_sys_create_datetime'), 'ai_app', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_ai_app_sys_creator_id'), 'ai_app', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_ai_app_sys_dept_id'), 'ai_app', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_ai_app_sys_update_datetime'), 'ai_app', ['sys_update_datetime'], unique=False) op.create_table('ai_conversation', sa.Column('app_id', sa.String(length=21), nullable=False, comment='所属应用ID(逻辑外键关联ai_app)'), sa.Column('user_id', sa.String(length=21), nullable=False, comment='用户ID(逻辑外键关联core_user)'), sa.Column('title', sa.String(length=200), nullable=True, comment='对话标题'), sa.Column('model_override_id', sa.String(length=21), nullable=True, comment='覆盖模型ID(逻辑外键关联ai_llm_model)'), sa.Column('temperature_override', sa.Float(), nullable=True, comment='覆盖温度参数'), sa.Column('message_count', sa.Integer(), nullable=True, comment='消息数量'), sa.Column('total_tokens', sa.Integer(), nullable=True, comment='总 Token 数'), sa.Column('is_pinned', sa.Boolean(), nullable=True, comment='是否置顶'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_ai_conversation_app_id'), 'ai_conversation', ['app_id'], unique=False) op.create_index(op.f('ix_ai_conversation_is_deleted'), 'ai_conversation', ['is_deleted'], unique=False) op.create_index(op.f('ix_ai_conversation_sys_create_datetime'), 'ai_conversation', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_ai_conversation_sys_creator_id'), 'ai_conversation', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_ai_conversation_sys_dept_id'), 'ai_conversation', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_ai_conversation_sys_update_datetime'), 'ai_conversation', ['sys_update_datetime'], unique=False) op.create_index('ix_ai_conversation_user_app', 'ai_conversation', ['user_id', 'app_id'], unique=False) op.create_index(op.f('ix_ai_conversation_user_id'), 'ai_conversation', ['user_id'], unique=False) op.create_table('ai_knowledge_annotation', sa.Column('knowledge_base_id', sa.String(length=21), nullable=False, comment='所属知识库ID(逻辑外键关联ai_knowledge_base)'), sa.Column('question', sa.Text(), nullable=False, comment='问题'), sa.Column('answer', sa.Text(), nullable=False, comment='答案'), sa.Column('embedding_status', sa.String(length=20), nullable=True, comment='向量化状态: pending/completed/failed'), sa.Column('enabled', sa.Boolean(), nullable=True, comment='是否启用'), sa.Column('hit_count', sa.Integer(), nullable=True, comment='命中次数'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('idx_annotation_kb_enabled', 'ai_knowledge_annotation', ['knowledge_base_id', 'enabled'], unique=False) op.create_index(op.f('ix_ai_knowledge_annotation_is_deleted'), 'ai_knowledge_annotation', ['is_deleted'], unique=False) op.create_index(op.f('ix_ai_knowledge_annotation_knowledge_base_id'), 'ai_knowledge_annotation', ['knowledge_base_id'], unique=False) op.create_index(op.f('ix_ai_knowledge_annotation_sys_create_datetime'), 'ai_knowledge_annotation', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_ai_knowledge_annotation_sys_creator_id'), 'ai_knowledge_annotation', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_ai_knowledge_annotation_sys_dept_id'), 'ai_knowledge_annotation', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_ai_knowledge_annotation_sys_update_datetime'), 'ai_knowledge_annotation', ['sys_update_datetime'], unique=False) op.create_table('ai_knowledge_base', sa.Column('application_id', sa.String(length=21), nullable=True, comment='所属应用ID(逻辑外键关联core_application)'), sa.Column('is_global', sa.Boolean(), nullable=True, comment='是否在子应用中可见'), sa.Column('name', sa.String(length=100), nullable=False, comment='知识库名称'), sa.Column('code', sa.String(length=100), nullable=False, comment='知识库编码'), sa.Column('description', sa.Text(), nullable=True, comment='描述'), sa.Column('icon', sa.String(length=50), nullable=True, comment='图标'), sa.Column('embedding_model_id', sa.String(length=21), nullable=True, comment='Embedding 模型ID(逻辑外键关联ai_llm_model)'), sa.Column('embedding_dimensions', sa.Integer(), nullable=True, comment='向量维度'), sa.Column('chunk_strategy', sa.String(length=20), nullable=True, comment='分块策略: recursive/semantic/markdown/fixed'), sa.Column('chunk_size', sa.Integer(), nullable=True, comment='分块大小(字符数)'), sa.Column('chunk_overlap', sa.Integer(), nullable=True, comment='分块重叠大小(字符数)'), sa.Column('separator', sa.String(length=50), nullable=True, comment='自定义分隔符'), sa.Column('retrieval_mode', sa.String(length=20), nullable=True, comment='检索模式: vector/fulltext/hybrid'), sa.Column('top_k', sa.Integer(), nullable=True, comment='检索返回数量'), sa.Column('score_threshold', sa.Float(), nullable=True, comment='相似度阈值(0-1)'), sa.Column('rerank_enabled', sa.Boolean(), nullable=True, comment='是否启用重排序'), sa.Column('rerank_model_id', sa.String(length=21), nullable=True, comment='重排序模型ID'), sa.Column('retrieval_weight', sa.Float(), nullable=True, comment='检索权重(多知识库检索时的加权系数,0.1-10.0)'), sa.Column('process_rules', sa.JSON(), nullable=True, comment='预处理规则(清洗配置)'), sa.Column('indexing_technique', sa.String(length=20), nullable=True, comment='索引模式: high_quality/economy'), sa.Column('document_count', sa.Integer(), nullable=True, comment='文档数量'), sa.Column('segment_count', sa.Integer(), nullable=True, comment='分段数量'), sa.Column('total_token_count', sa.Integer(), nullable=True, comment='总 Token 数'), sa.Column('total_char_count', sa.Integer(), nullable=True, comment='总字符数'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: active/disabled'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('code') ) op.create_index(op.f('ix_ai_knowledge_base_application_id'), 'ai_knowledge_base', ['application_id'], unique=False) op.create_index(op.f('ix_ai_knowledge_base_is_deleted'), 'ai_knowledge_base', ['is_deleted'], unique=False) op.create_index(op.f('ix_ai_knowledge_base_sys_create_datetime'), 'ai_knowledge_base', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_ai_knowledge_base_sys_creator_id'), 'ai_knowledge_base', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_ai_knowledge_base_sys_dept_id'), 'ai_knowledge_base', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_ai_knowledge_base_sys_update_datetime'), 'ai_knowledge_base', ['sys_update_datetime'], unique=False) op.create_table('ai_knowledge_document', sa.Column('knowledge_base_id', sa.String(length=21), nullable=False, comment='所属知识库ID(逻辑外键关联ai_knowledge_base)'), sa.Column('file_id', sa.String(length=21), nullable=True, comment='关联文件ID(逻辑外键关联core_file_manager)'), sa.Column('name', sa.String(length=255), nullable=False, comment='文档名称'), sa.Column('file_type', sa.String(length=20), nullable=True, comment='文件类型: pdf/docx/txt/md/xlsx/csv/html/pptx'), sa.Column('file_size', sa.BigInteger(), nullable=True, comment='文件大小(字节)'), sa.Column('content_hash', sa.String(length=64), nullable=True, comment='内容MD5(用于去重)'), sa.Column('segment_count', sa.Integer(), nullable=True, comment='分段数量'), sa.Column('token_count', sa.Integer(), nullable=True, comment='Token 总数'), sa.Column('char_count', sa.Integer(), nullable=True, comment='字符总数'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: pending/indexing/completed/failed/disabled'), sa.Column('error_message', sa.Text(), nullable=True, comment='错误信息'), sa.Column('indexing_started_at', sa.DateTime(), nullable=True, comment='索引开始时间'), sa.Column('indexing_completed_at', sa.DateTime(), nullable=True, comment='索引完成时间'), sa.Column('duplicate_warning', sa.Text(), nullable=True, comment='内容重复警告(跨知识库检测)'), sa.Column('enabled', sa.Boolean(), nullable=True, comment='是否启用(禁用后不参与检索)'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_ai_knowledge_document_content_hash'), 'ai_knowledge_document', ['content_hash'], unique=False) op.create_index(op.f('ix_ai_knowledge_document_is_deleted'), 'ai_knowledge_document', ['is_deleted'], unique=False) op.create_index(op.f('ix_ai_knowledge_document_knowledge_base_id'), 'ai_knowledge_document', ['knowledge_base_id'], unique=False) op.create_index(op.f('ix_ai_knowledge_document_status'), 'ai_knowledge_document', ['status'], unique=False) op.create_index(op.f('ix_ai_knowledge_document_sys_create_datetime'), 'ai_knowledge_document', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_ai_knowledge_document_sys_creator_id'), 'ai_knowledge_document', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_ai_knowledge_document_sys_dept_id'), 'ai_knowledge_document', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_ai_knowledge_document_sys_update_datetime'), 'ai_knowledge_document', ['sys_update_datetime'], unique=False) op.create_table('ai_knowledge_retrieval_log', sa.Column('query', sa.Text(), nullable=False, comment='查询文本'), sa.Column('knowledge_base_ids', sa.JSON(), nullable=False, comment='检索的知识库ID列表'), sa.Column('retrieval_mode', sa.String(length=20), nullable=True, comment='检索模式: vector/fulltext/hybrid'), sa.Column('top_k', sa.Integer(), nullable=True, comment='请求的返回数量'), sa.Column('score_threshold', sa.Float(), nullable=True, comment='相似度阈值'), sa.Column('result_count', sa.Integer(), nullable=True, comment='实际返回结果数'), sa.Column('results', sa.JSON(), nullable=True, comment='检索结果摘要(segment_id/score/kb_id)'), sa.Column('rerank_applied', sa.String(length=5), nullable=True, comment='是否应用了重排序'), sa.Column('elapsed_time', sa.Integer(), nullable=True, comment='耗时(毫秒)'), sa.Column('source', sa.String(length=50), nullable=True, comment='调用来源: api/workflow/chat'), sa.Column('user_id', sa.String(length=21), nullable=True, comment='操作用户ID'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('idx_retrieval_log_query_time', 'ai_knowledge_retrieval_log', ['sys_create_datetime'], unique=False) op.create_index('idx_retrieval_log_user', 'ai_knowledge_retrieval_log', ['user_id'], unique=False) op.create_index(op.f('ix_ai_knowledge_retrieval_log_is_deleted'), 'ai_knowledge_retrieval_log', ['is_deleted'], unique=False) op.create_index(op.f('ix_ai_knowledge_retrieval_log_sys_create_datetime'), 'ai_knowledge_retrieval_log', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_ai_knowledge_retrieval_log_sys_creator_id'), 'ai_knowledge_retrieval_log', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_ai_knowledge_retrieval_log_sys_dept_id'), 'ai_knowledge_retrieval_log', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_ai_knowledge_retrieval_log_sys_update_datetime'), 'ai_knowledge_retrieval_log', ['sys_update_datetime'], unique=False) op.create_table('ai_knowledge_segment', sa.Column('knowledge_base_id', sa.String(length=21), nullable=False, comment='所属知识库ID(逻辑外键关联ai_knowledge_base)'), sa.Column('document_id', sa.String(length=21), nullable=False, comment='所属文档ID(逻辑外键关联ai_knowledge_document)'), sa.Column('position', sa.Integer(), nullable=True, comment='在文档中的位置序号'), sa.Column('content', sa.Text(), nullable=False, comment='分段文本内容'), sa.Column('answer', sa.Text(), nullable=True, comment='Q&A 模式的答案内容'), sa.Column('token_count', sa.Integer(), nullable=True, comment='Token 数'), sa.Column('char_count', sa.Integer(), nullable=True, comment='字符数'), sa.Column('word_count', sa.Integer(), nullable=True, comment='词数'), sa.Column('page_number', sa.Integer(), nullable=True, comment='来源页码(PDF/PPT)'), sa.Column('keywords', sa.JSON(), nullable=True, comment='关键词列表(用于全文检索增强)'), sa.Column('extra_metadata', sa.JSON(), nullable=True, comment='元数据(标题/来源等)'), sa.Column('embedding_status', sa.String(length=20), nullable=True, comment='向量化状态: pending/completed/failed'), sa.Column('parent_segment_id', sa.String(length=21), nullable=True, comment='父分段ID(逻辑外键,用于 Small-to-Big 检索)'), sa.Column('enabled', sa.Boolean(), nullable=True, comment='是否启用(禁用后不参与检索)'), sa.Column('hit_count', sa.Integer(), nullable=True, comment='命中次数'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('idx_segment_kb_doc', 'ai_knowledge_segment', ['knowledge_base_id', 'document_id'], unique=False) op.create_index('idx_segment_kb_enabled', 'ai_knowledge_segment', ['knowledge_base_id', 'enabled'], unique=False) op.create_index(op.f('ix_ai_knowledge_segment_document_id'), 'ai_knowledge_segment', ['document_id'], unique=False) op.create_index(op.f('ix_ai_knowledge_segment_is_deleted'), 'ai_knowledge_segment', ['is_deleted'], unique=False) op.create_index(op.f('ix_ai_knowledge_segment_knowledge_base_id'), 'ai_knowledge_segment', ['knowledge_base_id'], unique=False) op.create_index(op.f('ix_ai_knowledge_segment_parent_segment_id'), 'ai_knowledge_segment', ['parent_segment_id'], unique=False) op.create_index(op.f('ix_ai_knowledge_segment_sys_create_datetime'), 'ai_knowledge_segment', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_ai_knowledge_segment_sys_creator_id'), 'ai_knowledge_segment', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_ai_knowledge_segment_sys_dept_id'), 'ai_knowledge_segment', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_ai_knowledge_segment_sys_update_datetime'), 'ai_knowledge_segment', ['sys_update_datetime'], unique=False) op.create_table('ai_llm_model', sa.Column('provider_id', sa.String(length=21), nullable=False, comment='所属提供商ID(逻辑外键关联ai_llm_provider)'), sa.Column('model_name', sa.String(length=100), nullable=False, comment='模型名称(API 调用时使用)'), sa.Column('display_name', sa.String(length=100), nullable=False, comment='显示名称'), sa.Column('model_type', sa.String(length=20), nullable=True, comment='模型类型: chat/completion/embedding/rerank'), sa.Column('max_tokens', sa.Integer(), nullable=True, comment='最大 Token 数'), sa.Column('context_window', sa.Integer(), nullable=True, comment='上下文窗口大小'), sa.Column('default_temperature', sa.Float(), nullable=True, comment='默认温度参数'), sa.Column('default_top_p', sa.Float(), nullable=True, comment='默认 top_p 参数'), sa.Column('input_price', sa.Numeric(precision=10, scale=6), nullable=True, comment='输入价格(每 1K tokens)'), sa.Column('output_price', sa.Numeric(precision=10, scale=6), nullable=True, comment='输出价格(每 1K tokens)'), sa.Column('is_active', sa.Boolean(), nullable=True, comment='是否启用'), sa.Column('supports_vision', sa.Boolean(), nullable=True, comment='是否支持视觉(图片输入)'), sa.Column('supports_function_call', sa.Boolean(), nullable=True, comment='是否支持函数调用'), sa.Column('supports_streaming', sa.Boolean(), nullable=True, comment='是否支持流式输出'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_ai_llm_model_is_deleted'), 'ai_llm_model', ['is_deleted'], unique=False) op.create_index(op.f('ix_ai_llm_model_provider_id'), 'ai_llm_model', ['provider_id'], unique=False) op.create_index(op.f('ix_ai_llm_model_sys_create_datetime'), 'ai_llm_model', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_ai_llm_model_sys_creator_id'), 'ai_llm_model', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_ai_llm_model_sys_dept_id'), 'ai_llm_model', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_ai_llm_model_sys_update_datetime'), 'ai_llm_model', ['sys_update_datetime'], unique=False) op.create_table('ai_llm_provider', sa.Column('name', sa.String(length=100), nullable=False, comment='提供商名称'), sa.Column('provider_type', sa.String(length=50), nullable=False, comment='提供商类型'), sa.Column('api_key', sa.Text(), nullable=True, comment='API Key(加密存储)'), sa.Column('api_base', sa.String(length=500), nullable=True, comment='API 地址(可选,用于自定义端点)'), sa.Column('api_version', sa.String(length=50), nullable=True, comment='API 版本(Azure OpenAI 专用)'), sa.Column('ollama_host', sa.String(length=200), nullable=True, comment='Ollama 服务地址'), sa.Column('is_active', sa.Boolean(), nullable=True, comment='是否启用'), sa.Column('description', sa.Text(), nullable=True, comment='描述'), sa.Column('quota_limit', sa.Integer(), nullable=True, comment='配额限制(0 表示无限制)'), sa.Column('quota_used', sa.Integer(), nullable=True, comment='已使用配额'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_ai_llm_provider_is_deleted'), 'ai_llm_provider', ['is_deleted'], unique=False) op.create_index(op.f('ix_ai_llm_provider_sys_create_datetime'), 'ai_llm_provider', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_ai_llm_provider_sys_creator_id'), 'ai_llm_provider', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_ai_llm_provider_sys_dept_id'), 'ai_llm_provider', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_ai_llm_provider_sys_update_datetime'), 'ai_llm_provider', ['sys_update_datetime'], unique=False) op.create_table('ai_message', sa.Column('conversation_id', sa.String(length=21), nullable=False, comment='所属对话ID(逻辑外键关联ai_conversation)'), sa.Column('role', sa.String(length=20), nullable=False, comment='角色: system/user/assistant'), sa.Column('content', sa.Text(), nullable=False, comment='消息内容'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: pending/completed/failed/stopped'), sa.Column('prompt_tokens', sa.Integer(), nullable=True, comment='提示 Token 数'), sa.Column('completion_tokens', sa.Integer(), nullable=True, comment='补全 Token 数'), sa.Column('total_tokens', sa.Integer(), nullable=True, comment='总 Token 数'), sa.Column('model_name', sa.String(length=100), nullable=True, comment='使用的模型名称'), sa.Column('latency', sa.Integer(), nullable=True, comment='响应耗时(毫秒)'), sa.Column('error_message', sa.Text(), nullable=True, comment='错误信息'), sa.Column('parent_message_id', sa.String(length=21), nullable=True, comment='父消息ID(逻辑外键关联自身)'), sa.Column('feedback', sa.String(length=20), nullable=True, comment='用户反馈: like/dislike'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('ix_ai_message_conversation_created', 'ai_message', ['conversation_id', 'sys_create_datetime'], unique=False) op.create_index(op.f('ix_ai_message_conversation_id'), 'ai_message', ['conversation_id'], unique=False) op.create_index(op.f('ix_ai_message_is_deleted'), 'ai_message', ['is_deleted'], unique=False) op.create_index(op.f('ix_ai_message_sys_create_datetime'), 'ai_message', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_ai_message_sys_creator_id'), 'ai_message', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_ai_message_sys_dept_id'), 'ai_message', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_ai_message_sys_update_datetime'), 'ai_message', ['sys_update_datetime'], unique=False) op.create_table('ai_prompt_template', sa.Column('name', sa.String(length=100), nullable=False, comment='模板名称'), sa.Column('code', sa.String(length=100), nullable=False, comment='模板编码'), sa.Column('category', sa.String(length=20), nullable=True, comment='分类: system/user/assistant/few_shot'), sa.Column('description', sa.Text(), nullable=True, comment='描述'), sa.Column('content', sa.Text(), nullable=False, comment='模板内容'), sa.Column('variables', sa.JSON(), nullable=True, comment='变量定义列表'), sa.Column('tags', sa.JSON(), nullable=True, comment='标签列表'), sa.Column('is_public', sa.Boolean(), nullable=True, comment='是否公开'), sa.Column('usage_count', sa.Integer(), nullable=True, comment='使用次数'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('code') ) op.create_index(op.f('ix_ai_prompt_template_is_deleted'), 'ai_prompt_template', ['is_deleted'], unique=False) op.create_index(op.f('ix_ai_prompt_template_sys_create_datetime'), 'ai_prompt_template', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_ai_prompt_template_sys_creator_id'), 'ai_prompt_template', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_ai_prompt_template_sys_dept_id'), 'ai_prompt_template', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_ai_prompt_template_sys_update_datetime'), 'ai_prompt_template', ['sys_update_datetime'], unique=False) op.create_table('ai_workflow', sa.Column('application_id', sa.String(length=21), nullable=True, comment='所属应用ID(逻辑外键关联core_application)'), sa.Column('is_global', sa.Boolean(), nullable=True, comment='是否在子应用中可见'), sa.Column('name', sa.String(length=100), nullable=False, comment='工作流名称'), sa.Column('code', sa.String(length=100), nullable=False, comment='工作流编码'), sa.Column('workflow_type', sa.String(length=30), nullable=True, comment='工作流类型: general/application/form/report/data_process/automation'), sa.Column('description', sa.Text(), nullable=True, comment='描述'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: draft/published/disabled'), sa.Column('version', sa.Integer(), nullable=True, comment='当前草稿版本号'), sa.Column('published_version', sa.Integer(), nullable=True, comment='已发布的版本号'), sa.Column('published_at', sa.DateTime(), nullable=True, comment='最后发布时间'), sa.Column('published_definition', sa.JSON(), nullable=True, comment='已发布版本的工作流定义'), sa.Column('definition', sa.JSON(), nullable=True, comment='工作流定义(草稿)'), sa.Column('input_variables', sa.JSON(), nullable=True, comment='输入变量定义'), sa.Column('output_variables', sa.JSON(), nullable=True, comment='输出变量定义'), sa.Column('run_count', sa.Integer(), nullable=True, comment='运行次数'), sa.Column('success_count', sa.Integer(), nullable=True, comment='成功次数'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('code') ) op.create_index(op.f('ix_ai_workflow_application_id'), 'ai_workflow', ['application_id'], unique=False) op.create_index(op.f('ix_ai_workflow_is_deleted'), 'ai_workflow', ['is_deleted'], unique=False) op.create_index(op.f('ix_ai_workflow_sys_create_datetime'), 'ai_workflow', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_ai_workflow_sys_creator_id'), 'ai_workflow', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_ai_workflow_sys_dept_id'), 'ai_workflow', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_ai_workflow_sys_update_datetime'), 'ai_workflow', ['sys_update_datetime'], unique=False) op.create_table('ai_workflow_run', sa.Column('workflow_id', sa.String(length=21), nullable=False, comment='工作流ID(逻辑外键关联ai_workflow)'), sa.Column('app_id', sa.String(length=21), nullable=True, comment='关联应用ID(逻辑外键关联ai_app)'), sa.Column('conversation_id', sa.String(length=21), nullable=True, comment='关联对话ID(逻辑外键关联ai_conversation)'), sa.Column('user_id', sa.String(length=21), nullable=True, comment='执行用户ID(逻辑外键关联core_user)'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: pending/running/completed/failed/stopped'), sa.Column('inputs', sa.JSON(), nullable=True, comment='输入数据'), sa.Column('outputs', sa.JSON(), nullable=True, comment='输出数据'), sa.Column('execution_log', sa.JSON(), nullable=True, comment='执行日志'), sa.Column('current_node_id', sa.String(length=100), nullable=True, comment='当前节点 ID'), sa.Column('waiting_config', sa.JSON(), nullable=True, comment='等待用户输入的配置'), sa.Column('error_message', sa.Text(), nullable=True, comment='错误信息'), sa.Column('total_tokens', sa.Integer(), nullable=True, comment='总 Token 数'), sa.Column('total_steps', sa.Integer(), nullable=True, comment='总步骤数'), sa.Column('elapsed_time', sa.Integer(), nullable=True, comment='总耗时(毫秒)'), sa.Column('started_at', sa.DateTime(), nullable=True, comment='开始时间'), sa.Column('completed_at', sa.DateTime(), nullable=True, comment='完成时间'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_ai_workflow_run_app_id'), 'ai_workflow_run', ['app_id'], unique=False) op.create_index(op.f('ix_ai_workflow_run_is_deleted'), 'ai_workflow_run', ['is_deleted'], unique=False) op.create_index(op.f('ix_ai_workflow_run_sys_create_datetime'), 'ai_workflow_run', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_ai_workflow_run_sys_creator_id'), 'ai_workflow_run', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_ai_workflow_run_sys_dept_id'), 'ai_workflow_run', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_ai_workflow_run_sys_update_datetime'), 'ai_workflow_run', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_ai_workflow_run_user_id'), 'ai_workflow_run', ['user_id'], unique=False) op.create_index('ix_ai_workflow_run_user_status', 'ai_workflow_run', ['user_id', 'status'], unique=False) op.create_index(op.f('ix_ai_workflow_run_workflow_id'), 'ai_workflow_run', ['workflow_id'], unique=False) op.create_index('ix_ai_workflow_run_workflow_status', 'ai_workflow_run', ['workflow_id', 'status'], unique=False) op.create_table('ai_workflow_version', sa.Column('workflow_id', sa.String(length=21), nullable=False, comment='工作流ID(逻辑外键关联ai_workflow)'), sa.Column('version', sa.Integer(), nullable=False, comment='版本号'), sa.Column('definition', sa.JSON(), nullable=True, comment='该版本的工作流定义'), sa.Column('description', sa.Text(), nullable=True, comment='版本说明'), sa.Column('published_by_id', sa.String(length=21), nullable=True, comment='发布人ID(逻辑外键关联core_user)'), sa.Column('published_at', sa.DateTime(), nullable=True, comment='发布时间'), sa.Column('run_count', sa.Integer(), nullable=True, comment='运行次数'), sa.Column('success_count', sa.Integer(), nullable=True, comment='成功次数'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_ai_workflow_version_is_deleted'), 'ai_workflow_version', ['is_deleted'], unique=False) op.create_index(op.f('ix_ai_workflow_version_sys_create_datetime'), 'ai_workflow_version', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_ai_workflow_version_sys_creator_id'), 'ai_workflow_version', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_ai_workflow_version_sys_dept_id'), 'ai_workflow_version', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_ai_workflow_version_sys_update_datetime'), 'ai_workflow_version', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_ai_workflow_version_workflow_id'), 'ai_workflow_version', ['workflow_id'], unique=False) op.create_table('code_sequence', sa.Column('business_type', sa.String(length=100), nullable=False, comment='业务类型'), sa.Column('prefix', sa.String(length=50), nullable=True, comment='前缀'), sa.Column('date_key', sa.String(length=20), nullable=True, comment='日期键(用于按日期重置)'), sa.Column('current_seq', sa.Integer(), nullable=True, comment='当前序号'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('idx_business_prefix_date', 'code_sequence', ['business_type', 'prefix', 'date_key'], unique=False) op.create_index(op.f('ix_code_sequence_is_deleted'), 'code_sequence', ['is_deleted'], unique=False) op.create_index(op.f('ix_code_sequence_sys_create_datetime'), 'code_sequence', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_code_sequence_sys_creator_id'), 'code_sequence', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_code_sequence_sys_dept_id'), 'code_sequence', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_code_sequence_sys_update_datetime'), 'code_sequence', ['sys_update_datetime'], unique=False) op.create_table('contract_instance', sa.Column('template_id', sa.String(length=21), nullable=False, comment='合同模板ID'), sa.Column('contract_no', sa.String(length=50), nullable=False, comment='合同编号'), sa.Column('title', sa.String(length=200), nullable=False, comment='合同标题'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: draft/pending/signing/completed/expired/canceled'), sa.Column('creator_id', sa.String(length=21), nullable=False, comment='创建人ID'), sa.Column('contract_config', sa.JSON(), nullable=True, comment='合同配置'), sa.Column('variable_data', sa.JSON(), nullable=True, comment='变量数据'), sa.Column('signature_data', sa.JSON(), nullable=True, comment='签署数据'), sa.Column('created_at', sa.DateTime(), nullable=True, comment='创建时间'), sa.Column('completed_at', sa.DateTime(), nullable=True, comment='完成时间'), sa.Column('expired_at', sa.DateTime(), nullable=True, comment='过期时间'), sa.Column('pdf_file', sa.Text(), nullable=True, comment='PDF文件路径'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('contract_no') ) op.create_index(op.f('ix_contract_instance_creator_id'), 'contract_instance', ['creator_id'], unique=False) op.create_index(op.f('ix_contract_instance_is_deleted'), 'contract_instance', ['is_deleted'], unique=False) op.create_index(op.f('ix_contract_instance_status'), 'contract_instance', ['status'], unique=False) op.create_index(op.f('ix_contract_instance_sys_create_datetime'), 'contract_instance', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_contract_instance_sys_creator_id'), 'contract_instance', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_contract_instance_sys_dept_id'), 'contract_instance', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_contract_instance_sys_update_datetime'), 'contract_instance', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_contract_instance_template_id'), 'contract_instance', ['template_id'], unique=False) op.create_table('contract_log', sa.Column('contract_id', sa.String(length=21), nullable=False, comment='合同实例ID'), sa.Column('action', sa.String(length=20), nullable=False, comment='操作类型: create/update/submit/sign/reject/cancel/complete/export/view'), sa.Column('operator_id', sa.String(length=21), nullable=False, comment='操作人ID'), sa.Column('comment', sa.Text(), nullable=True, comment='备注'), sa.Column('extra_data', sa.JSON(), nullable=True, comment='额外数据'), sa.Column('ip_address', sa.String(length=50), nullable=True, comment='IP地址'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_contract_log_contract_id'), 'contract_log', ['contract_id'], unique=False) op.create_index(op.f('ix_contract_log_is_deleted'), 'contract_log', ['is_deleted'], unique=False) op.create_index(op.f('ix_contract_log_sys_create_datetime'), 'contract_log', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_contract_log_sys_creator_id'), 'contract_log', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_contract_log_sys_dept_id'), 'contract_log', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_contract_log_sys_update_datetime'), 'contract_log', ['sys_update_datetime'], unique=False) op.create_table('contract_sign_token', sa.Column('contract_id', sa.String(length=21), nullable=False, comment='合同实例ID'), sa.Column('token', sa.String(length=64), nullable=False, comment='签署令牌'), sa.Column('party_type', sa.String(length=20), nullable=True, comment='签署方类型'), sa.Column('signer_name', sa.String(length=50), nullable=True, comment='签署人姓名'), sa.Column('expired_at', sa.DateTime(), nullable=False, comment='过期时间'), sa.Column('is_used', sa.Boolean(), nullable=True, comment='是否已使用'), sa.Column('used_at', sa.DateTime(), nullable=True, comment='使用时间'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('token') ) op.create_index(op.f('ix_contract_sign_token_contract_id'), 'contract_sign_token', ['contract_id'], unique=False) op.create_index(op.f('ix_contract_sign_token_is_deleted'), 'contract_sign_token', ['is_deleted'], unique=False) op.create_index(op.f('ix_contract_sign_token_sys_create_datetime'), 'contract_sign_token', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_contract_sign_token_sys_creator_id'), 'contract_sign_token', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_contract_sign_token_sys_dept_id'), 'contract_sign_token', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_contract_sign_token_sys_update_datetime'), 'contract_sign_token', ['sys_update_datetime'], unique=False) op.create_table('contract_signature', sa.Column('contract_id', sa.String(length=21), nullable=False, comment='合同实例ID'), sa.Column('element_id', sa.String(length=50), nullable=False, comment='元素ID'), sa.Column('party_type', sa.String(length=20), nullable=True, comment='签署方类型: party_a/party_b/party_c/witness'), sa.Column('party_label', sa.String(length=50), nullable=True, comment='签署方标签'), sa.Column('sign_type', sa.String(length=20), nullable=True, comment='签署类型: signature/seal'), sa.Column('signer_id', sa.String(length=21), nullable=True, comment='签署人ID'), sa.Column('signer_name', sa.String(length=50), nullable=True, comment='签署人姓名'), sa.Column('signature_image', sa.Text(), nullable=True, comment='签名/印章图片(base64)'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: pending/signed/rejected'), sa.Column('signed_at', sa.DateTime(), nullable=True, comment='签署时间'), sa.Column('sign_ip', sa.String(length=50), nullable=True, comment='签署IP'), sa.Column('sign_device', sa.String(length=200), nullable=True, comment='签署设备'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_contract_signature_contract_id'), 'contract_signature', ['contract_id'], unique=False) op.create_index(op.f('ix_contract_signature_is_deleted'), 'contract_signature', ['is_deleted'], unique=False) op.create_index(op.f('ix_contract_signature_sys_create_datetime'), 'contract_signature', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_contract_signature_sys_creator_id'), 'contract_signature', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_contract_signature_sys_dept_id'), 'contract_signature', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_contract_signature_sys_update_datetime'), 'contract_signature', ['sys_update_datetime'], unique=False) op.create_table('contract_template', sa.Column('name', sa.String(length=100), nullable=False, comment='模板名称'), sa.Column('code', sa.String(length=100), nullable=False, comment='模板编码'), sa.Column('category', sa.String(length=50), nullable=True, comment='分类'), sa.Column('description', sa.Text(), nullable=True, comment='描述'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: draft/published/disabled'), sa.Column('version', sa.Integer(), nullable=True, comment='版本号'), sa.Column('template_config', sa.JSON(), nullable=True, comment='模板配置'), sa.Column('thumbnail', sa.Text(), nullable=True, comment='缩略图(base64)'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('code') ) op.create_index(op.f('ix_contract_template_is_deleted'), 'contract_template', ['is_deleted'], unique=False) op.create_index(op.f('ix_contract_template_status'), 'contract_template', ['status'], unique=False) op.create_index(op.f('ix_contract_template_sys_create_datetime'), 'contract_template', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_contract_template_sys_creator_id'), 'contract_template', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_contract_template_sys_dept_id'), 'contract_template', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_contract_template_sys_update_datetime'), 'contract_template', ['sys_update_datetime'], unique=False) op.create_table('core_announcement', sa.Column('title', sa.String(length=200), nullable=False, comment='公告标题'), sa.Column('content', sa.Text(), nullable=False, comment='公告内容'), sa.Column('summary', sa.String(length=500), nullable=True, comment='摘要'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: draft/published/expired'), sa.Column('priority', sa.Integer(), nullable=True, comment='优先级: 0普通/1重要/2紧急'), sa.Column('is_top', sa.Boolean(), nullable=True, comment='是否置顶'), sa.Column('target_type', sa.String(length=20), nullable=True, comment='接收范围类型: all/dept/role/user'), sa.Column('target_ids', sa.JSON(), nullable=True, comment='接收目标ID列表'), sa.Column('publish_time', sa.DateTime(), nullable=True, comment='发布时间'), sa.Column('expire_time', sa.DateTime(), nullable=True, comment='过期时间'), sa.Column('publisher_id', sa.String(length=50), nullable=True, comment='发布人ID'), sa.Column('read_count', sa.Integer(), nullable=True, comment='阅读次数'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_announcement_is_deleted'), 'core_announcement', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_announcement_priority'), 'core_announcement', ['priority'], unique=False) op.create_index(op.f('ix_core_announcement_status'), 'core_announcement', ['status'], unique=False) op.create_index(op.f('ix_core_announcement_sys_create_datetime'), 'core_announcement', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_announcement_sys_creator_id'), 'core_announcement', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_announcement_sys_dept_id'), 'core_announcement', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_announcement_sys_update_datetime'), 'core_announcement', ['sys_update_datetime'], unique=False) op.create_table('core_announcement_read', sa.Column('announcement_id', sa.String(length=50), nullable=False, comment='公告ID'), sa.Column('user_id', sa.String(length=50), nullable=False, comment='用户ID'), sa.Column('read_at', sa.DateTime(), nullable=True, comment='阅读时间'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('ix_announcement_read_unique', 'core_announcement_read', ['announcement_id', 'user_id'], unique=True) op.create_index(op.f('ix_core_announcement_read_announcement_id'), 'core_announcement_read', ['announcement_id'], unique=False) op.create_index(op.f('ix_core_announcement_read_is_deleted'), 'core_announcement_read', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_announcement_read_sys_create_datetime'), 'core_announcement_read', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_announcement_read_sys_creator_id'), 'core_announcement_read', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_announcement_read_sys_dept_id'), 'core_announcement_read', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_announcement_read_sys_update_datetime'), 'core_announcement_read', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_core_announcement_read_user_id'), 'core_announcement_read', ['user_id'], unique=False) op.create_table('core_api_token', sa.Column('name', sa.String(length=100), nullable=False, comment='令牌名称'), sa.Column('token_hash', sa.String(length=64), nullable=False, comment='令牌哈希值(SHA-256)'), sa.Column('token_prefix', sa.String(length=255), nullable=False, comment='令牌前缀(用于识别)'), sa.Column('user_id', sa.String(length=21), nullable=False, comment='所属用户ID'), sa.Column('expires_at', sa.DateTime(), nullable=True, comment='过期时间(NULL表示永不过期)'), sa.Column('last_used_at', sa.DateTime(), nullable=True, comment='最后使用时间'), sa.Column('description', sa.Text(), nullable=True, comment='令牌描述'), sa.Column('is_active', sa.Boolean(), nullable=True, comment='是否启用'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_api_token_is_deleted'), 'core_api_token', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_api_token_sys_create_datetime'), 'core_api_token', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_api_token_sys_creator_id'), 'core_api_token', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_api_token_sys_dept_id'), 'core_api_token', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_api_token_sys_update_datetime'), 'core_api_token', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_core_api_token_token_hash'), 'core_api_token', ['token_hash'], unique=True) op.create_index(op.f('ix_core_api_token_user_id'), 'core_api_token', ['user_id'], unique=False) op.create_table('core_application', sa.Column('name', sa.String(length=100), nullable=False, comment='应用名称'), sa.Column('code', sa.String(length=100), nullable=False, comment='应用编码(唯一标识,用于URL路由)'), sa.Column('description', sa.Text(), nullable=True, comment='应用描述'), sa.Column('icon', sa.String(length=100), nullable=True, comment='应用图标'), sa.Column('cover', sa.String(length=500), nullable=True, comment='应用封面图URL'), sa.Column('app_type', sa.String(length=20), nullable=True, comment='应用类型'), sa.Column('status', sa.String(length=20), nullable=True, comment='应用状态'), sa.Column('home_path', sa.String(length=200), nullable=True, comment='应用首页路径'), sa.Column('version', sa.Integer(), nullable=True, comment='版本号'), sa.Column('config', sa.JSON(), nullable=True, comment='应用配置'), sa.Column('owner_id', sa.String(length=21), nullable=True, comment='所有者ID'), sa.Column('team_ids', sa.JSON(), nullable=True, comment='团队成员ID列表'), sa.Column('system_menu_ids', sa.JSON(), nullable=True, comment='开发模式下显示的系统菜单ID列表'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_application_app_type'), 'core_application', ['app_type'], unique=False) op.create_index(op.f('ix_core_application_code'), 'core_application', ['code'], unique=True) op.create_index(op.f('ix_core_application_is_deleted'), 'core_application', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_application_owner_id'), 'core_application', ['owner_id'], unique=False) op.create_index(op.f('ix_core_application_status'), 'core_application', ['status'], unique=False) op.create_index(op.f('ix_core_application_sys_create_datetime'), 'core_application', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_application_sys_creator_id'), 'core_application', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_application_sys_dept_id'), 'core_application', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_application_sys_update_datetime'), 'core_application', ['sys_update_datetime'], unique=False) op.create_table('core_chat_message', sa.Column('conversation_id', sa.String(length=21), nullable=False, comment='会话ID(逻辑外键关联core_conversation)'), sa.Column('sender_id', sa.String(length=21), nullable=False, comment='发送者用户ID(逻辑外键关联core_user)'), sa.Column('msg_type', sa.String(length=20), nullable=True, comment='消息类型: text/image/file/voice/system/recall'), sa.Column('content', sa.Text(), nullable=True, comment='文本内容'), sa.Column('file_id', sa.String(length=21), nullable=True, comment='文件ID(逻辑外键关联core_file_manager)'), sa.Column('reply_to_id', sa.String(length=21), nullable=True, comment='回复的消息ID(逻辑外键)'), sa.Column('is_recalled', sa.Boolean(), nullable=True, comment='是否已撤回'), sa.Column('recalled_at', sa.DateTime(), nullable=True, comment='撤回时间'), sa.Column('extra', sa.JSON(), nullable=True, comment='扩展数据(@提醒列表、链接预览等)'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('idx_chat_msg_conv_id_created', 'core_chat_message', ['conversation_id', 'sys_create_datetime'], unique=False) op.create_index('idx_chat_msg_sender_id', 'core_chat_message', ['sender_id'], unique=False) op.create_index(op.f('ix_core_chat_message_is_deleted'), 'core_chat_message', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_chat_message_sys_create_datetime'), 'core_chat_message', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_chat_message_sys_creator_id'), 'core_chat_message', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_chat_message_sys_dept_id'), 'core_chat_message', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_chat_message_sys_update_datetime'), 'core_chat_message', ['sys_update_datetime'], unique=False) op.create_table('core_conversation', sa.Column('type', sa.String(length=20), nullable=False, comment='会话类型: private/group'), sa.Column('name', sa.String(length=100), nullable=True, comment='群聊名称(单聊为空)'), sa.Column('avatar', sa.String(length=500), nullable=True, comment='群头像文件ID'), sa.Column('owner_id', sa.String(length=21), nullable=True, comment='群主用户ID(逻辑外键关联core_user)'), sa.Column('last_message_id', sa.String(length=21), nullable=True, comment='最后一条消息ID(逻辑外键)'), sa.Column('last_message_time', sa.DateTime(), nullable=True, comment='最后消息时间'), sa.Column('last_message_preview', sa.String(length=200), nullable=True, comment='最后消息预览文本'), sa.Column('member_count', sa.Integer(), nullable=True, comment='成员数'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('idx_conversation_last_msg_time', 'core_conversation', ['last_message_time'], unique=False) op.create_index('idx_conversation_type', 'core_conversation', ['type'], unique=False) op.create_index(op.f('ix_core_conversation_is_deleted'), 'core_conversation', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_conversation_sys_create_datetime'), 'core_conversation', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_conversation_sys_creator_id'), 'core_conversation', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_conversation_sys_dept_id'), 'core_conversation', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_conversation_sys_update_datetime'), 'core_conversation', ['sys_update_datetime'], unique=False) op.create_table('core_conversation_member', sa.Column('conversation_id', sa.String(length=21), nullable=False, comment='会话ID(逻辑外键关联core_conversation)'), sa.Column('user_id', sa.String(length=21), nullable=False, comment='用户ID(逻辑外键关联core_user)'), sa.Column('role', sa.String(length=20), nullable=True, comment='角色: owner/admin/member'), sa.Column('nickname', sa.String(length=50), nullable=True, comment='群内昵称'), sa.Column('is_muted', sa.Boolean(), nullable=True, comment='是否免打扰'), sa.Column('is_pinned', sa.Boolean(), nullable=True, comment='是否置顶'), sa.Column('unread_count', sa.Integer(), nullable=True, comment='未读消息数'), sa.Column('last_read_message_id', sa.String(length=21), nullable=True, comment='最后已读消息ID'), sa.Column('joined_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='加入时间'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('idx_conv_member_conv_id', 'core_conversation_member', ['conversation_id'], unique=False) op.create_index('idx_conv_member_conv_user', 'core_conversation_member', ['conversation_id', 'user_id'], unique=True) op.create_index('idx_conv_member_user_id', 'core_conversation_member', ['user_id'], unique=False) op.create_index(op.f('ix_core_conversation_member_is_deleted'), 'core_conversation_member', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_conversation_member_sys_create_datetime'), 'core_conversation_member', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_conversation_member_sys_creator_id'), 'core_conversation_member', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_conversation_member_sys_dept_id'), 'core_conversation_member', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_conversation_member_sys_update_datetime'), 'core_conversation_member', ['sys_update_datetime'], unique=False) op.create_table('core_data_source', sa.Column('application_id', sa.String(length=21), nullable=True, comment='所属应用ID'), sa.Column('name', sa.String(length=100), nullable=False, comment='数据源名称'), sa.Column('code', sa.String(length=50), nullable=False, comment='数据源编码(唯一标识)'), sa.Column('source_type', sa.String(length=20), nullable=True, comment='数据源类型: api/sql/static'), sa.Column('description', sa.Text(), nullable=True, comment='描述说明'), sa.Column('status', sa.Boolean(), nullable=True, comment='是否启用'), sa.Column('api_url', sa.String(length=500), nullable=True, comment='API地址,支持 {param} 占位符'), sa.Column('api_method', sa.String(length=10), nullable=True, comment='请求方法: GET/POST/PUT/DELETE/PATCH'), sa.Column('api_headers', sa.JSON(), nullable=True, comment='请求头配置'), sa.Column('api_query_params', sa.JSON(), nullable=True, comment='Query参数列表 [{key, value, description, enabled}]'), sa.Column('api_body_type', sa.String(length=20), nullable=True, comment='请求体类型: none/json/form-data/x-www-form-urlencoded/raw'), sa.Column('api_body', sa.JSON(), nullable=True, comment='请求体模板'), sa.Column('api_content_type', sa.String(length=50), nullable=True, comment='Content-Type,raw模式时使用'), sa.Column('api_timeout', sa.Integer(), nullable=True, comment='请求超时时间(秒)'), sa.Column('api_data_path', sa.String(length=100), nullable=True, comment='响应数据路径,如 data.list'), sa.Column('api_auth_type', sa.String(length=20), nullable=True, comment='认证类型: none/bearer_token/basic_auth/api_key'), sa.Column('api_auth_config', sa.JSON(), nullable=True, comment='认证配置 {token, username, password, key_name, key_value, key_position}'), sa.Column('api_retry_count', sa.Integer(), nullable=True, comment='重试次数(0表示不重试)'), sa.Column('api_retry_interval', sa.Integer(), nullable=True, comment='重试间隔(秒)'), sa.Column('api_success_condition', sa.JSON(), nullable=True, comment='成功条件 {status_codes, field_path, field_value}'), sa.Column('api_proxy', sa.String(length=200), nullable=True, comment='代理地址'), sa.Column('api_follow_redirects', sa.Boolean(), nullable=True, comment='是否跟随重定向'), sa.Column('api_verify_ssl', sa.Boolean(), nullable=True, comment='是否验证SSL证书'), sa.Column('sql_content', sa.Text(), nullable=True, comment='SQL语句,使用 :param 作为参数占位符'), sa.Column('db_connection', sa.String(length=50), nullable=True, comment='数据库连接名称'), sa.Column('static_data', sa.JSON(), nullable=True, comment='静态数据(JSON 数组)'), sa.Column('params', sa.JSON(), nullable=True, comment='参数定义列表'), sa.Column('result_type', sa.String(length=20), nullable=True, comment='结果类型: list/tree/object/value/chart-*'), sa.Column('tree_config', sa.JSON(), nullable=True, comment='树形转换配置'), sa.Column('field_mapping', sa.JSON(), nullable=True, comment='字段映射配置'), sa.Column('chart_config', sa.JSON(), nullable=True, comment='图表配置'), sa.Column('cache_enabled', sa.Boolean(), nullable=True, comment='是否启用缓存'), sa.Column('cache_ttl', sa.Integer(), nullable=True, comment='缓存时间(秒)'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_data_source_application_id'), 'core_data_source', ['application_id'], unique=False) op.create_index(op.f('ix_core_data_source_code'), 'core_data_source', ['code'], unique=True) op.create_index(op.f('ix_core_data_source_is_deleted'), 'core_data_source', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_data_source_sys_create_datetime'), 'core_data_source', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_data_source_sys_creator_id'), 'core_data_source', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_data_source_sys_dept_id'), 'core_data_source', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_data_source_sys_update_datetime'), 'core_data_source', ['sys_update_datetime'], unique=False) op.create_table('core_dept', sa.Column('name', sa.String(length=64), nullable=False, comment='部门名称'), sa.Column('code', sa.String(length=32), nullable=True, comment='部门编码'), sa.Column('dept_type', sa.String(length=20), nullable=True, comment='部门类型'), sa.Column('phone', sa.String(length=20), nullable=True, comment='部门电话'), sa.Column('email', sa.String(length=64), nullable=True, comment='部门邮箱'), sa.Column('status', sa.Boolean(), nullable=True, comment='部门状态'), sa.Column('description', sa.Text(), nullable=True, comment='部门描述'), sa.Column('parent_id', sa.String(length=21), nullable=True, comment='父部门ID'), sa.Column('lead_id', sa.String(length=21), nullable=True, comment='部门领导ID'), sa.Column('level', sa.Integer(), nullable=True, comment='部门层级'), sa.Column('path', sa.String(length=500), nullable=True, comment='部门路径'), sa.Column('dingtalk_dept_id', sa.String(length=64), nullable=True, comment='钉钉部门ID'), sa.Column('wecom_dept_id', sa.String(length=64), nullable=True, comment='企业微信部门ID'), sa.Column('feishu_dept_id', sa.String(length=128), nullable=True, comment='飞书部门ID'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_dept_code'), 'core_dept', ['code'], unique=True) op.create_index(op.f('ix_core_dept_dept_type'), 'core_dept', ['dept_type'], unique=False) op.create_index(op.f('ix_core_dept_dingtalk_dept_id'), 'core_dept', ['dingtalk_dept_id'], unique=True) op.create_index(op.f('ix_core_dept_feishu_dept_id'), 'core_dept', ['feishu_dept_id'], unique=True) op.create_index(op.f('ix_core_dept_is_deleted'), 'core_dept', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_dept_level'), 'core_dept', ['level'], unique=False) op.create_index(op.f('ix_core_dept_name'), 'core_dept', ['name'], unique=False) op.create_index(op.f('ix_core_dept_parent_id'), 'core_dept', ['parent_id'], unique=False) op.create_index(op.f('ix_core_dept_path'), 'core_dept', ['path'], unique=False) op.create_index(op.f('ix_core_dept_status'), 'core_dept', ['status'], unique=False) op.create_index(op.f('ix_core_dept_sys_create_datetime'), 'core_dept', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_dept_sys_creator_id'), 'core_dept', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_dept_sys_dept_id'), 'core_dept', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_dept_sys_update_datetime'), 'core_dept', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_core_dept_wecom_dept_id'), 'core_dept', ['wecom_dept_id'], unique=True) op.create_table('core_dict', sa.Column('application_id', sa.String(length=21), nullable=True, comment='所属应用ID'), sa.Column('is_global', sa.Boolean(), nullable=True, comment='是否全局可见'), sa.Column('name', sa.String(length=100), nullable=False, comment='字典名称'), sa.Column('code', sa.String(length=100), nullable=False, comment='字典编码'), sa.Column('status', sa.Boolean(), nullable=True, comment='状态'), sa.Column('remark', sa.Text(), nullable=True, comment='备注'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_dict_application_id'), 'core_dict', ['application_id'], unique=False) op.create_index(op.f('ix_core_dict_code'), 'core_dict', ['code'], unique=True) op.create_index(op.f('ix_core_dict_is_deleted'), 'core_dict', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_dict_name'), 'core_dict', ['name'], unique=False) op.create_index(op.f('ix_core_dict_status'), 'core_dict', ['status'], unique=False) op.create_index(op.f('ix_core_dict_sys_create_datetime'), 'core_dict', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_dict_sys_creator_id'), 'core_dict', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_dict_sys_dept_id'), 'core_dict', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_dict_sys_update_datetime'), 'core_dict', ['sys_update_datetime'], unique=False) op.create_table('core_dict_item', sa.Column('dict_id', sa.String(length=36), nullable=False, comment='字典ID'), sa.Column('label', sa.String(length=100), nullable=True, comment='显示名称'), sa.Column('value', sa.String(length=100), nullable=True, comment='实际值'), sa.Column('icon', sa.String(length=100), nullable=True, comment='图标'), sa.Column('status', sa.Boolean(), nullable=True, comment='状态'), sa.Column('remark', sa.Text(), nullable=True, comment='备注'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_dict_item_dict_id'), 'core_dict_item', ['dict_id'], unique=False) op.create_index(op.f('ix_core_dict_item_is_deleted'), 'core_dict_item', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_dict_item_label'), 'core_dict_item', ['label'], unique=False) op.create_index(op.f('ix_core_dict_item_status'), 'core_dict_item', ['status'], unique=False) op.create_index(op.f('ix_core_dict_item_sys_create_datetime'), 'core_dict_item', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_dict_item_sys_creator_id'), 'core_dict_item', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_dict_item_sys_dept_id'), 'core_dict_item', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_dict_item_sys_update_datetime'), 'core_dict_item', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_core_dict_item_value'), 'core_dict_item', ['value'], unique=False) op.create_table('core_dingtalk_sync_log', sa.Column('sync_type', sa.String(length=20), nullable=False, comment='同步类型: dept/user'), sa.Column('total_count', sa.Integer(), nullable=True, comment='总数'), sa.Column('success_count', sa.Integer(), nullable=True, comment='成功数'), sa.Column('fail_count', sa.Integer(), nullable=True, comment='失败数'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: running/success/partial/failed'), sa.Column('error_detail', sa.Text(), nullable=True, comment='失败详情'), sa.Column('started_at', sa.DateTime(), nullable=True, comment='开始时间'), sa.Column('finished_at', sa.DateTime(), nullable=True, comment='结束时间'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_dingtalk_sync_log_is_deleted'), 'core_dingtalk_sync_log', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_dingtalk_sync_log_status'), 'core_dingtalk_sync_log', ['status'], unique=False) op.create_index(op.f('ix_core_dingtalk_sync_log_sync_type'), 'core_dingtalk_sync_log', ['sync_type'], unique=False) op.create_index(op.f('ix_core_dingtalk_sync_log_sys_create_datetime'), 'core_dingtalk_sync_log', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_dingtalk_sync_log_sys_creator_id'), 'core_dingtalk_sync_log', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_dingtalk_sync_log_sys_dept_id'), 'core_dingtalk_sync_log', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_dingtalk_sync_log_sys_update_datetime'), 'core_dingtalk_sync_log', ['sys_update_datetime'], unique=False) op.create_table('core_feishu_sync_log', sa.Column('sync_type', sa.String(length=20), nullable=False, comment='同步类型: dept/user'), sa.Column('total_count', sa.Integer(), nullable=True, comment='总数'), sa.Column('success_count', sa.Integer(), nullable=True, comment='成功数'), sa.Column('fail_count', sa.Integer(), nullable=True, comment='失败数'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: running/success/partial/failed'), sa.Column('error_detail', sa.Text(), nullable=True, comment='失败详情'), sa.Column('started_at', sa.DateTime(), nullable=True, comment='开始时间'), sa.Column('finished_at', sa.DateTime(), nullable=True, comment='结束时间'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_feishu_sync_log_is_deleted'), 'core_feishu_sync_log', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_feishu_sync_log_status'), 'core_feishu_sync_log', ['status'], unique=False) op.create_index(op.f('ix_core_feishu_sync_log_sync_type'), 'core_feishu_sync_log', ['sync_type'], unique=False) op.create_index(op.f('ix_core_feishu_sync_log_sys_create_datetime'), 'core_feishu_sync_log', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_feishu_sync_log_sys_creator_id'), 'core_feishu_sync_log', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_feishu_sync_log_sys_dept_id'), 'core_feishu_sync_log', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_feishu_sync_log_sys_update_datetime'), 'core_feishu_sync_log', ['sys_update_datetime'], unique=False) op.create_table('core_file_access_token', sa.Column('token', sa.String(length=64), nullable=False, comment='临时访问令牌'), sa.Column('file_id', sa.String(length=36), nullable=False, comment='文件ID'), sa.Column('expires_at', sa.DateTime(), nullable=False, comment='过期时间'), sa.Column('user_id', sa.String(length=36), nullable=True, comment='用户ID'), sa.Column('ip_address', sa.String(length=45), nullable=True, comment='IP地址'), sa.Column('user_agent', sa.String(length=500), nullable=True, comment='User Agent'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('token') ) op.create_index(op.f('ix_core_file_access_token_is_deleted'), 'core_file_access_token', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_file_access_token_sys_create_datetime'), 'core_file_access_token', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_file_access_token_sys_creator_id'), 'core_file_access_token', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_file_access_token_sys_dept_id'), 'core_file_access_token', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_file_access_token_sys_update_datetime'), 'core_file_access_token', ['sys_update_datetime'], unique=False) op.create_index('ix_file_access_token_expires_at', 'core_file_access_token', ['expires_at'], unique=False) op.create_index('ix_file_access_token_file_id', 'core_file_access_token', ['file_id'], unique=False) op.create_index('ix_file_access_token_token', 'core_file_access_token', ['token'], unique=False) op.create_table('core_file_manager', sa.Column('name', sa.String(length=255), nullable=False, comment='文件/文件夹名称'), sa.Column('type', sa.String(length=10), nullable=True, comment='类型: file/folder'), sa.Column('parent_id', sa.String(length=36), nullable=True, comment='父文件夹ID'), sa.Column('path', sa.Text(), nullable=False, comment='文件路径'), sa.Column('size', sa.BigInteger(), nullable=True, comment='文件大小(字节)'), sa.Column('file_ext', sa.String(length=50), nullable=True, comment='文件扩展名'), sa.Column('mime_type', sa.String(length=200), nullable=True, comment='MIME类型'), sa.Column('storage_type', sa.String(length=20), nullable=True, comment='存储类型: local/oss/minio/azure'), sa.Column('storage_path', sa.Text(), nullable=False, comment='存储路径'), sa.Column('url', sa.Text(), nullable=True, comment='访问URL'), sa.Column('thumbnail_url', sa.Text(), nullable=True, comment='缩略图URL'), sa.Column('md5', sa.String(length=32), nullable=True, comment='文件MD5'), sa.Column('is_public', sa.Boolean(), nullable=True, comment='是否公开'), sa.Column('download_count', sa.Integer(), nullable=True, comment='下载次数'), sa.Column('is_system', sa.Boolean(), nullable=True, comment='是否系统文件夹(不可删除/重命名)'), sa.Column('source', sa.String(length=50), nullable=True, comment='来源模块标识'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_file_manager_is_deleted'), 'core_file_manager', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_file_manager_sys_create_datetime'), 'core_file_manager', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_file_manager_sys_creator_id'), 'core_file_manager', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_file_manager_sys_dept_id'), 'core_file_manager', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_file_manager_sys_update_datetime'), 'core_file_manager', ['sys_update_datetime'], unique=False) op.create_index('ix_file_manager_md5', 'core_file_manager', ['md5'], unique=False) op.create_index('ix_file_manager_parent_type', 'core_file_manager', ['parent_id', 'type'], unique=False) op.create_index('ix_file_manager_storage_type', 'core_file_manager', ['storage_type'], unique=False) op.create_table('core_login_log', sa.Column('user_id', sa.String(length=36), nullable=True, comment='用户ID'), sa.Column('username', sa.String(length=150), nullable=False, comment='用户名'), sa.Column('login_type', sa.String(length=20), nullable=True, comment='登录方式'), sa.Column('status', sa.Integer(), nullable=True, comment='登录状态'), sa.Column('failure_reason', sa.Integer(), nullable=True, comment='登录失败原因'), sa.Column('failure_message', sa.String(length=255), nullable=True, comment='登录失败详细信息'), sa.Column('login_ip', sa.String(length=50), nullable=False, comment='登录IP地址'), sa.Column('ip_location', sa.String(length=100), nullable=True, comment='IP属地'), sa.Column('user_agent', sa.Text(), nullable=True, comment='用户代理字符串'), sa.Column('browser_type', sa.String(length=50), nullable=True, comment='浏览器类型'), sa.Column('os_type', sa.String(length=50), nullable=True, comment='操作系统类型'), sa.Column('device_type', sa.String(length=20), nullable=True, comment='设备类型'), sa.Column('duration', sa.Integer(), nullable=True, comment='登录会话时长(秒)'), sa.Column('session_id', sa.String(length=128), nullable=True, comment='会话ID'), sa.Column('remark', sa.String(length=255), nullable=True, comment='备注信息'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('session_id') ) op.create_index(op.f('ix_core_login_log_is_deleted'), 'core_login_log', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_login_log_login_ip'), 'core_login_log', ['login_ip'], unique=False) op.create_index(op.f('ix_core_login_log_login_type'), 'core_login_log', ['login_type'], unique=False) op.create_index(op.f('ix_core_login_log_status'), 'core_login_log', ['status'], unique=False) op.create_index(op.f('ix_core_login_log_sys_create_datetime'), 'core_login_log', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_login_log_sys_creator_id'), 'core_login_log', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_login_log_sys_dept_id'), 'core_login_log', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_login_log_sys_update_datetime'), 'core_login_log', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_core_login_log_user_id'), 'core_login_log', ['user_id'], unique=False) op.create_index(op.f('ix_core_login_log_username'), 'core_login_log', ['username'], unique=False) op.create_index('ix_login_log_ip_datetime', 'core_login_log', ['login_ip', 'sys_create_datetime'], unique=False) op.create_index('ix_login_log_status_datetime', 'core_login_log', ['status', 'sys_create_datetime'], unique=False) op.create_index('ix_login_log_type_datetime', 'core_login_log', ['login_type', 'sys_create_datetime'], unique=False) op.create_index('ix_login_log_user_datetime', 'core_login_log', ['user_id', 'sys_create_datetime'], unique=False) op.create_index('ix_login_log_user_type', 'core_login_log', ['user_id', 'login_type'], unique=False) op.create_index('ix_login_log_username_status', 'core_login_log', ['username', 'status'], unique=False) op.create_table('core_menu', sa.Column('application_id', sa.String(length=21), nullable=True, comment='所属应用ID'), sa.Column('is_system', sa.Boolean(), nullable=True, comment='是否为系统菜单'), sa.Column('parent_id', sa.String(length=21), nullable=True, comment='父菜单ID'), sa.Column('name', sa.String(length=100), nullable=False, comment='菜单名称(路由名称)'), sa.Column('title', sa.String(length=100), nullable=True, comment='菜单标题(显示名称)'), sa.Column('authCode', sa.String(length=100), nullable=True, comment='后端权限标识'), sa.Column('path', sa.String(length=200), nullable=False, comment='路由路径'), sa.Column('type', sa.String(length=20), nullable=True, comment='菜单类型: catalog/menu/external/online_form/online_page/agent'), sa.Column('component', sa.String(length=100), nullable=True, comment='组件路径'), sa.Column('redirect', sa.String(length=200), nullable=True, comment='重定向路径'), sa.Column('activePath', sa.String(length=200), nullable=True, comment='激活路径'), sa.Column('query', sa.JSON(), nullable=True, comment='额外路由参数'), sa.Column('noBasicLayout', sa.Boolean(), nullable=True, comment='无需基础布局'), sa.Column('icon', sa.String(length=100), nullable=True, comment='菜单图标'), sa.Column('activeIcon', sa.String(length=100), nullable=True, comment='激活图标'), sa.Column('order', sa.Integer(), nullable=True, comment='菜单排序'), sa.Column('hideInMenu', sa.Boolean(), nullable=True, comment='在菜单中隐藏'), sa.Column('hideChildrenInMenu', sa.Boolean(), nullable=True, comment='在菜单中隐藏下级'), sa.Column('hideInBreadcrumb', sa.Boolean(), nullable=True, comment='在面包屑中隐藏'), sa.Column('hideInTab', sa.Boolean(), nullable=True, comment='在标签栏中隐藏'), sa.Column('affixTab', sa.Boolean(), nullable=True, comment='固定在标签栏'), sa.Column('affixTabOrder', sa.Integer(), nullable=True, comment='标签栏固定顺序'), sa.Column('keepAlive', sa.Boolean(), nullable=True, comment='缓存页面'), sa.Column('maxNumOfOpenTab', sa.Integer(), nullable=True, comment='最大打开标签数'), sa.Column('fullPathKey', sa.Boolean(), nullable=True, comment='路由完整路径作为key(设为false时路径参数变化不刷新组件)'), sa.Column('link', sa.String(length=500), nullable=True, comment='外链URL'), sa.Column('iframeSrc', sa.String(length=500), nullable=True, comment='内嵌iframe URL'), sa.Column('openInNewWindow', sa.Boolean(), nullable=True, comment='在新窗口打开'), sa.Column('badge', sa.String(length=20), nullable=True, comment='徽标内容'), sa.Column('badgeType', sa.String(length=20), nullable=True, comment='徽标类型: dot/normal'), sa.Column('badgeVariants', sa.String(length=20), nullable=True, comment='徽标颜色'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_menu_application_id'), 'core_menu', ['application_id'], unique=False) op.create_index(op.f('ix_core_menu_is_deleted'), 'core_menu', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_menu_parent_id'), 'core_menu', ['parent_id'], unique=False) op.create_index(op.f('ix_core_menu_sys_create_datetime'), 'core_menu', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_menu_sys_creator_id'), 'core_menu', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_menu_sys_dept_id'), 'core_menu', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_menu_sys_update_datetime'), 'core_menu', ['sys_update_datetime'], unique=False) op.create_table('core_message', sa.Column('recipient_id', sa.String(length=50), nullable=False, comment='接收人ID'), sa.Column('title', sa.String(length=200), nullable=False, comment='消息标题'), sa.Column('content', sa.Text(), nullable=False, comment='消息内容'), sa.Column('msg_type', sa.String(length=20), nullable=True, comment='消息类型: system/workflow/todo/announcement'), sa.Column('status', sa.String(length=20), nullable=True, comment='消息状态: unread/read'), sa.Column('link_type', sa.String(length=50), nullable=True, comment='关联类型'), sa.Column('link_id', sa.String(length=50), nullable=True, comment='关联对象ID'), sa.Column('read_at', sa.DateTime(), nullable=True, comment='阅读时间'), sa.Column('sender_id', sa.String(length=50), nullable=True, comment='发送人ID'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_message_is_deleted'), 'core_message', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_message_msg_type'), 'core_message', ['msg_type'], unique=False) op.create_index(op.f('ix_core_message_recipient_id'), 'core_message', ['recipient_id'], unique=False) op.create_index(op.f('ix_core_message_status'), 'core_message', ['status'], unique=False) op.create_index(op.f('ix_core_message_sys_create_datetime'), 'core_message', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_message_sys_creator_id'), 'core_message', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_message_sys_dept_id'), 'core_message', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_message_sys_update_datetime'), 'core_message', ['sys_update_datetime'], unique=False) op.create_index('ix_message_recipient_status', 'core_message', ['recipient_id', 'status'], unique=False) op.create_index('ix_message_recipient_type', 'core_message', ['recipient_id', 'msg_type'], unique=False) op.create_table('core_permission', sa.Column('menu_id', sa.String(length=21), nullable=False, comment='关联菜单ID(逻辑外键关联core_menu)'), sa.Column('name', sa.String(length=64), nullable=False, comment='权限名称'), sa.Column('code', sa.String(length=64), nullable=False, comment='权限编码'), sa.Column('permission_type', sa.Integer(), nullable=True, comment='权限类型(1-API权限'), sa.Column('api_path', sa.String(length=200), nullable=True, comment='API路径'), sa.Column('http_method', sa.Integer(), nullable=True, comment='HTTP方法(0-GET, 1-POST, 2-PUT, 3-DELETE, 4-PATCH, 5-ALL)'), sa.Column('description', sa.Text(), nullable=True, comment='权限描述'), sa.Column('is_active', sa.Boolean(), nullable=True, comment='是否启用'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('menu_id', 'code', name='uq_permission_menu_code') ) op.create_index(op.f('ix_core_permission_code'), 'core_permission', ['code'], unique=False) op.create_index(op.f('ix_core_permission_is_active'), 'core_permission', ['is_active'], unique=False) op.create_index(op.f('ix_core_permission_is_deleted'), 'core_permission', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_permission_menu_id'), 'core_permission', ['menu_id'], unique=False) op.create_index(op.f('ix_core_permission_name'), 'core_permission', ['name'], unique=False) op.create_index(op.f('ix_core_permission_permission_type'), 'core_permission', ['permission_type'], unique=False) op.create_index(op.f('ix_core_permission_sys_create_datetime'), 'core_permission', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_permission_sys_creator_id'), 'core_permission', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_permission_sys_dept_id'), 'core_permission', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_permission_sys_update_datetime'), 'core_permission', ['sys_update_datetime'], unique=False) op.create_table('core_post', sa.Column('name', sa.String(length=64), nullable=False, comment='岗位名称'), sa.Column('code', sa.String(length=32), nullable=False, comment='岗位编码'), sa.Column('post_type', sa.Integer(), nullable=True, comment='岗位类型(0-管理岗, 1-技术岗, 2-业务岗, 3-职能岗, 4-其他)'), sa.Column('post_level', sa.Integer(), nullable=True, comment='岗位级别(0-高层, 1-中层, 2-基层, 3-一般员工)'), sa.Column('status', sa.Boolean(), nullable=True, comment='岗位状态(启用/禁用)'), sa.Column('description', sa.Text(), nullable=True, comment='岗位描述/职责'), sa.Column('dept_id', sa.String(length=21), nullable=True, comment='所属部门ID(逻辑外键关联core_dept)'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_post_code'), 'core_post', ['code'], unique=True) op.create_index(op.f('ix_core_post_dept_id'), 'core_post', ['dept_id'], unique=False) op.create_index(op.f('ix_core_post_is_deleted'), 'core_post', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_post_name'), 'core_post', ['name'], unique=False) op.create_index(op.f('ix_core_post_post_level'), 'core_post', ['post_level'], unique=False) op.create_index(op.f('ix_core_post_post_type'), 'core_post', ['post_type'], unique=False) op.create_index(op.f('ix_core_post_status'), 'core_post', ['status'], unique=False) op.create_index(op.f('ix_core_post_sys_create_datetime'), 'core_post', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_post_sys_creator_id'), 'core_post', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_post_sys_dept_id'), 'core_post', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_post_sys_update_datetime'), 'core_post', ['sys_update_datetime'], unique=False) op.create_table('core_province', sa.Column('code', sa.String(length=20), nullable=False, comment='省份代码'), sa.Column('name', sa.String(length=100), nullable=False, comment='省份名称'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_province_code'), 'core_province', ['code'], unique=True) op.create_index(op.f('ix_core_province_is_deleted'), 'core_province', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_province_sys_create_datetime'), 'core_province', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_province_sys_creator_id'), 'core_province', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_province_sys_dept_id'), 'core_province', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_province_sys_update_datetime'), 'core_province', ['sys_update_datetime'], unique=False) op.create_table('core_resource_data_scope_config', sa.Column('role_id', sa.String(length=21), nullable=False, comment='角色ID(逻辑外键关联core_role)'), sa.Column('resource_type', sa.String(length=50), nullable=False, comment='资源类型(如customer/order/post等)'), sa.Column('data_scope', sa.Integer(), nullable=True, comment='数据权限范围(0-全部, 1-仅本人, 2-本部门, 3-本部门及下级, 4-自定义)'), sa.Column('dept_ids', sa.JSON(), nullable=True, comment='自定义权限时的部门ID列表(JSON数组)'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('role_id', 'resource_type', name='uq_role_resource') ) op.create_index(op.f('ix_core_resource_data_scope_config_is_deleted'), 'core_resource_data_scope_config', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_resource_data_scope_config_resource_type'), 'core_resource_data_scope_config', ['resource_type'], unique=False) op.create_index(op.f('ix_core_resource_data_scope_config_role_id'), 'core_resource_data_scope_config', ['role_id'], unique=False) op.create_index(op.f('ix_core_resource_data_scope_config_sys_create_datetime'), 'core_resource_data_scope_config', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_resource_data_scope_config_sys_creator_id'), 'core_resource_data_scope_config', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_resource_data_scope_config_sys_dept_id'), 'core_resource_data_scope_config', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_resource_data_scope_config_sys_update_datetime'), 'core_resource_data_scope_config', ['sys_update_datetime'], unique=False) op.create_table('core_role', sa.Column('name', sa.String(length=64), nullable=False, comment='角色名称'), sa.Column('code', sa.String(length=64), nullable=False, comment='角色编码'), sa.Column('role_type', sa.Integer(), nullable=True, comment='角色类型(0-系统角色, 1-自定义角色)'), sa.Column('status', sa.Boolean(), nullable=True, comment='角色状态(启用/禁用)'), sa.Column('priority', sa.Integer(), nullable=True, comment='角色优先级(数字越大优先级越高)'), sa.Column('description', sa.Text(), nullable=True, comment='角色描述'), sa.Column('remark', sa.Text(), nullable=True, comment='备注信息'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_role_code'), 'core_role', ['code'], unique=True) op.create_index(op.f('ix_core_role_is_deleted'), 'core_role', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_role_name'), 'core_role', ['name'], unique=False) op.create_index(op.f('ix_core_role_priority'), 'core_role', ['priority'], unique=False) op.create_index(op.f('ix_core_role_role_type'), 'core_role', ['role_type'], unique=False) op.create_index(op.f('ix_core_role_status'), 'core_role', ['status'], unique=False) op.create_index(op.f('ix_core_role_sys_create_datetime'), 'core_role', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_role_sys_creator_id'), 'core_role', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_role_sys_dept_id'), 'core_role', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_role_sys_update_datetime'), 'core_role', ['sys_update_datetime'], unique=False) op.create_table('core_scheduler_job', sa.Column('application_id', sa.String(length=21), nullable=True, comment='所属应用ID'), sa.Column('name', sa.String(length=128), nullable=False, comment='任务名称'), sa.Column('code', sa.String(length=128), nullable=False, comment='任务编码'), sa.Column('description', sa.Text(), nullable=True, comment='任务描述'), sa.Column('group', sa.String(length=64), nullable=True, comment='任务分组'), sa.Column('trigger_type', sa.String(length=20), nullable=True, comment='触发器类型'), sa.Column('cron_expression', sa.String(length=128), nullable=True, comment='Cron表达式'), sa.Column('interval_seconds', sa.Integer(), nullable=True, comment='间隔时间(秒)'), sa.Column('run_date', sa.DateTime(), nullable=True, comment='指定执行时间'), sa.Column('task_func', sa.String(length=256), nullable=False, comment='任务函数路径'), sa.Column('task_args', sa.Text(), nullable=True, comment='任务位置参数(JSON数组格式)'), sa.Column('task_kwargs', sa.Text(), nullable=True, comment='任务关键字参数(JSON对象格式)'), sa.Column('status', sa.Integer(), nullable=True, comment='任务状态(0-禁用,1-启用,2-暂停)'), sa.Column('priority', sa.Integer(), nullable=True, comment='任务优先级'), sa.Column('max_instances', sa.Integer(), nullable=True, comment='最大实例数'), sa.Column('max_retries', sa.Integer(), nullable=True, comment='错误重试次数'), sa.Column('timeout', sa.Integer(), nullable=True, comment='超时时间(秒)'), sa.Column('coalesce', sa.Boolean(), nullable=True, comment='是否合并执行'), sa.Column('allow_concurrent', sa.Boolean(), nullable=True, comment='是否允许并发执行'), sa.Column('total_run_count', sa.Integer(), nullable=True, comment='总执行次数'), sa.Column('success_count', sa.Integer(), nullable=True, comment='成功次数'), sa.Column('failure_count', sa.Integer(), nullable=True, comment='失败次数'), sa.Column('last_run_time', sa.DateTime(), nullable=True, comment='最后执行时间'), sa.Column('next_run_time', sa.DateTime(), nullable=True, comment='下次执行时间'), sa.Column('last_run_status', sa.String(length=20), nullable=True, comment='最后执行状态'), sa.Column('last_run_result', sa.Text(), nullable=True, comment='最后执行结果'), sa.Column('remark', sa.Text(), nullable=True, comment='备注信息'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_scheduler_job_application_id'), 'core_scheduler_job', ['application_id'], unique=False) op.create_index(op.f('ix_core_scheduler_job_code'), 'core_scheduler_job', ['code'], unique=True) op.create_index(op.f('ix_core_scheduler_job_group'), 'core_scheduler_job', ['group'], unique=False) op.create_index(op.f('ix_core_scheduler_job_is_deleted'), 'core_scheduler_job', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_scheduler_job_name'), 'core_scheduler_job', ['name'], unique=False) op.create_index(op.f('ix_core_scheduler_job_priority'), 'core_scheduler_job', ['priority'], unique=False) op.create_index(op.f('ix_core_scheduler_job_status'), 'core_scheduler_job', ['status'], unique=False) op.create_index(op.f('ix_core_scheduler_job_sys_create_datetime'), 'core_scheduler_job', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_scheduler_job_sys_creator_id'), 'core_scheduler_job', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_scheduler_job_sys_dept_id'), 'core_scheduler_job', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_scheduler_job_sys_update_datetime'), 'core_scheduler_job', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_core_scheduler_job_trigger_type'), 'core_scheduler_job', ['trigger_type'], unique=False) op.create_index('ix_scheduler_job_group_status', 'core_scheduler_job', ['group', 'status'], unique=False) op.create_index('ix_scheduler_job_next_run_status', 'core_scheduler_job', ['next_run_time', 'status'], unique=False) op.create_index('ix_scheduler_job_priority_status', 'core_scheduler_job', ['priority', 'status'], unique=False) op.create_index('ix_scheduler_job_status_trigger', 'core_scheduler_job', ['status', 'trigger_type'], unique=False) op.create_table('core_scheduler_log', sa.Column('job_id', sa.String(length=36), nullable=False, comment='任务ID'), sa.Column('job_name', sa.String(length=128), nullable=False, comment='任务名称'), sa.Column('job_code', sa.String(length=128), nullable=False, comment='任务编码'), sa.Column('status', sa.String(length=20), nullable=True, comment='执行状态'), sa.Column('start_time', sa.DateTime(), nullable=False, comment='开始时间'), sa.Column('end_time', sa.DateTime(), nullable=True, comment='结束时间'), sa.Column('duration', sa.Float(), nullable=True, comment='执行耗时(秒)'), sa.Column('result', sa.Text(), nullable=True, comment='执行结果'), sa.Column('exception', sa.Text(), nullable=True, comment='异常信息'), sa.Column('traceback', sa.Text(), nullable=True, comment='异常堆栈'), sa.Column('hostname', sa.String(length=128), nullable=True, comment='执行主机'), sa.Column('process_id', sa.Integer(), nullable=True, comment='进程ID'), sa.Column('retry_count', sa.Integer(), nullable=True, comment='重试次数'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_scheduler_log_is_deleted'), 'core_scheduler_log', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_scheduler_log_job_code'), 'core_scheduler_log', ['job_code'], unique=False) op.create_index(op.f('ix_core_scheduler_log_job_id'), 'core_scheduler_log', ['job_id'], unique=False) op.create_index(op.f('ix_core_scheduler_log_job_name'), 'core_scheduler_log', ['job_name'], unique=False) op.create_index(op.f('ix_core_scheduler_log_start_time'), 'core_scheduler_log', ['start_time'], unique=False) op.create_index(op.f('ix_core_scheduler_log_status'), 'core_scheduler_log', ['status'], unique=False) op.create_index(op.f('ix_core_scheduler_log_sys_create_datetime'), 'core_scheduler_log', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_scheduler_log_sys_creator_id'), 'core_scheduler_log', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_scheduler_log_sys_dept_id'), 'core_scheduler_log', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_scheduler_log_sys_update_datetime'), 'core_scheduler_log', ['sys_update_datetime'], unique=False) op.create_index('ix_scheduler_log_code_start', 'core_scheduler_log', ['job_code', 'start_time'], unique=False) op.create_index('ix_scheduler_log_job_status', 'core_scheduler_log', ['job_id', 'status'], unique=False) op.create_index('ix_scheduler_log_status_start', 'core_scheduler_log', ['status', 'start_time'], unique=False) op.create_table('core_signature_token', sa.Column('token', sa.String(length=128), nullable=False, comment='令牌'), sa.Column('source', sa.String(length=50), nullable=True, comment='来源(form/workflow等)'), sa.Column('callback_key', sa.String(length=128), nullable=True, comment='回调标识(用于前端轮询)'), sa.Column('expired_at', sa.DateTime(), nullable=False, comment='过期时间'), sa.Column('is_used', sa.Boolean(), nullable=True, comment='是否已使用'), sa.Column('used_at', sa.DateTime(), nullable=True, comment='使用时间'), sa.Column('signature_file_id', sa.String(length=36), nullable=True, comment='签名文件ID'), sa.Column('user_id', sa.String(length=36), nullable=True, comment='创建用户ID'), sa.Column('ip_address', sa.String(length=64), nullable=True, comment='签名IP地址'), sa.Column('user_agent', sa.Text(), nullable=True, comment='签名设备信息'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_signature_token_is_deleted'), 'core_signature_token', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_signature_token_sys_create_datetime'), 'core_signature_token', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_signature_token_sys_creator_id'), 'core_signature_token', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_signature_token_sys_dept_id'), 'core_signature_token', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_signature_token_sys_update_datetime'), 'core_signature_token', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_core_signature_token_token'), 'core_signature_token', ['token'], unique=True) op.create_table('core_system_config', sa.Column('config_group', sa.String(length=50), nullable=False, comment='配置分组'), sa.Column('config_key', sa.String(length=100), nullable=False, comment='配置键'), sa.Column('config_value', sa.Text(), nullable=True, comment='配置值'), sa.Column('description', sa.String(length=200), nullable=True, comment='配置描述'), sa.Column('is_secret', sa.Boolean(), nullable=True, comment='是否敏感字段'), sa.Column('status', sa.Boolean(), nullable=True, comment='是否启用'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_system_config_config_group'), 'core_system_config', ['config_group'], unique=False) op.create_index(op.f('ix_core_system_config_config_key'), 'core_system_config', ['config_key'], unique=False) op.create_index(op.f('ix_core_system_config_is_deleted'), 'core_system_config', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_system_config_status'), 'core_system_config', ['status'], unique=False) op.create_index(op.f('ix_core_system_config_sys_create_datetime'), 'core_system_config', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_system_config_sys_creator_id'), 'core_system_config', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_system_config_sys_dept_id'), 'core_system_config', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_system_config_sys_update_datetime'), 'core_system_config', ['sys_update_datetime'], unique=False) op.create_table('core_ui_config', sa.Column('application_id', sa.String(length=21), nullable=True, comment='所属应用ID'), sa.Column('config_key', sa.String(length=100), nullable=False, comment='配置键'), sa.Column('config_value', sa.Text(), nullable=True, comment='配置值(JSON)'), sa.Column('config_type', sa.String(length=50), nullable=False, comment='配置类型'), sa.Column('description', sa.String(length=200), nullable=True, comment='配置描述'), sa.Column('status', sa.Boolean(), nullable=True, comment='状态'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_ui_config_application_id'), 'core_ui_config', ['application_id'], unique=False) op.create_index(op.f('ix_core_ui_config_config_key'), 'core_ui_config', ['config_key'], unique=False) op.create_index(op.f('ix_core_ui_config_config_type'), 'core_ui_config', ['config_type'], unique=False) op.create_index(op.f('ix_core_ui_config_is_deleted'), 'core_ui_config', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_ui_config_status'), 'core_ui_config', ['status'], unique=False) op.create_index(op.f('ix_core_ui_config_sys_create_datetime'), 'core_ui_config', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_ui_config_sys_creator_id'), 'core_ui_config', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_ui_config_sys_dept_id'), 'core_ui_config', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_ui_config_sys_update_datetime'), 'core_ui_config', ['sys_update_datetime'], unique=False) op.create_table('core_user', sa.Column('username', sa.String(length=150), nullable=False, comment='用户名'), sa.Column('password', sa.String(length=128), nullable=True, comment='密码'), sa.Column('is_superuser', sa.Boolean(), nullable=True, comment='是否超级管理员'), sa.Column('last_login', sa.DateTime(), nullable=True, comment='最后登录时间'), sa.Column('email', sa.String(length=255), nullable=True, comment='邮箱'), sa.Column('mobile', sa.String(length=11), nullable=True, comment='手机号'), sa.Column('avatar', sa.String(length=36), nullable=True, comment='头像UUID'), sa.Column('name', sa.String(length=64), nullable=True, comment='真实姓名'), sa.Column('gender', sa.Integer(), nullable=True, comment='性别'), sa.Column('user_type', sa.Integer(), nullable=True, comment='用户类型'), sa.Column('user_status', sa.Integer(), nullable=True, comment='用户状态'), sa.Column('birthday', sa.Date(), nullable=True, comment='生日'), sa.Column('city', sa.String(length=100), nullable=True, comment='所在城市'), sa.Column('address', sa.String(length=200), nullable=True, comment='详细地址'), sa.Column('bio', sa.Text(), nullable=True, comment='个人简介'), sa.Column('last_login_ip', sa.String(length=45), nullable=True, comment='最后登录IP'), sa.Column('last_login_type', sa.String(length=20), nullable=True, comment='最后登录方式'), sa.Column('is_active', sa.Boolean(), nullable=True, comment='是否激活'), sa.Column('dept_id', sa.String(length=21), nullable=True, comment='所属部门ID'), sa.Column('post_id', sa.String(length=21), nullable=True, comment='所属岗位ID'), sa.Column('role_id', sa.String(length=21), nullable=True, comment='所属角色ID(已废弃)'), sa.Column('manager_id', sa.String(length=21), nullable=True, comment='直属上级ID'), sa.Column('oauth_provider', sa.String(length=50), nullable=True, comment='OAuth提供商'), sa.Column('gitee_id', sa.String(length=200), nullable=True, comment='Gitee用户ID'), sa.Column('github_id', sa.String(length=200), nullable=True, comment='GitHub用户ID'), sa.Column('qq_id', sa.String(length=200), nullable=True, comment='QQ用户openid'), sa.Column('google_id', sa.String(length=200), nullable=True, comment='Google用户ID'), sa.Column('wechat_unionid', sa.String(length=200), nullable=True, comment='微信UnionID'), sa.Column('wechat_openid', sa.String(length=200), nullable=True, comment='微信OpenID'), sa.Column('microsoft_id', sa.String(length=200), nullable=True, comment='Microsoft用户ID'), sa.Column('dingtalk_unionid', sa.String(length=200), nullable=True, comment='钉钉UnionID'), sa.Column('dingtalk_userid', sa.String(length=200), nullable=True, comment='钉钉用户UserID'), sa.Column('feishu_union_id', sa.String(length=200), nullable=True, comment='飞书UnionID'), sa.Column('feishu_userid', sa.String(length=200), nullable=True, comment='飞书用户OpenID'), sa.Column('wecom_userid', sa.String(length=200), nullable=True, comment='企业微信UserID'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_user_dept_id'), 'core_user', ['dept_id'], unique=False) op.create_index(op.f('ix_core_user_dingtalk_unionid'), 'core_user', ['dingtalk_unionid'], unique=True) op.create_index(op.f('ix_core_user_dingtalk_userid'), 'core_user', ['dingtalk_userid'], unique=True) op.create_index(op.f('ix_core_user_email'), 'core_user', ['email'], unique=False) op.create_index(op.f('ix_core_user_feishu_union_id'), 'core_user', ['feishu_union_id'], unique=True) op.create_index(op.f('ix_core_user_feishu_userid'), 'core_user', ['feishu_userid'], unique=True) op.create_index(op.f('ix_core_user_gitee_id'), 'core_user', ['gitee_id'], unique=True) op.create_index(op.f('ix_core_user_github_id'), 'core_user', ['github_id'], unique=True) op.create_index(op.f('ix_core_user_google_id'), 'core_user', ['google_id'], unique=True) op.create_index(op.f('ix_core_user_is_active'), 'core_user', ['is_active'], unique=False) op.create_index(op.f('ix_core_user_is_deleted'), 'core_user', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_user_is_superuser'), 'core_user', ['is_superuser'], unique=False) op.create_index(op.f('ix_core_user_last_login_type'), 'core_user', ['last_login_type'], unique=False) op.create_index(op.f('ix_core_user_microsoft_id'), 'core_user', ['microsoft_id'], unique=True) op.create_index(op.f('ix_core_user_mobile'), 'core_user', ['mobile'], unique=False) op.create_index(op.f('ix_core_user_name'), 'core_user', ['name'], unique=False) op.create_index(op.f('ix_core_user_oauth_provider'), 'core_user', ['oauth_provider'], unique=False) op.create_index(op.f('ix_core_user_post_id'), 'core_user', ['post_id'], unique=False) op.create_index(op.f('ix_core_user_qq_id'), 'core_user', ['qq_id'], unique=True) op.create_index(op.f('ix_core_user_role_id'), 'core_user', ['role_id'], unique=False) op.create_index(op.f('ix_core_user_sys_create_datetime'), 'core_user', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_user_sys_creator_id'), 'core_user', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_user_sys_dept_id'), 'core_user', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_user_sys_update_datetime'), 'core_user', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_core_user_user_status'), 'core_user', ['user_status'], unique=False) op.create_index(op.f('ix_core_user_user_type'), 'core_user', ['user_type'], unique=False) op.create_index(op.f('ix_core_user_username'), 'core_user', ['username'], unique=True) op.create_index(op.f('ix_core_user_wechat_openid'), 'core_user', ['wechat_openid'], unique=False) op.create_index(op.f('ix_core_user_wechat_unionid'), 'core_user', ['wechat_unionid'], unique=True) op.create_index(op.f('ix_core_user_wecom_userid'), 'core_user', ['wecom_userid'], unique=True) op.create_table('core_user_role', sa.Column('user_id', sa.String(length=21), nullable=False, comment='用户ID'), sa.Column('role_id', sa.String(length=21), nullable=False, comment='角色ID'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('idx_user_role_unique', 'core_user_role', ['user_id', 'role_id'], unique=True) op.create_index(op.f('ix_core_user_role_is_deleted'), 'core_user_role', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_user_role_role_id'), 'core_user_role', ['role_id'], unique=False) op.create_index(op.f('ix_core_user_role_sys_create_datetime'), 'core_user_role', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_user_role_sys_creator_id'), 'core_user_role', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_user_role_sys_dept_id'), 'core_user_role', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_user_role_sys_update_datetime'), 'core_user_role', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_core_user_role_user_id'), 'core_user_role', ['user_id'], unique=False) op.create_table('core_wecom_sync_log', sa.Column('sync_type', sa.String(length=20), nullable=False, comment='同步类型: dept/user'), sa.Column('total_count', sa.Integer(), nullable=True, comment='总数'), sa.Column('success_count', sa.Integer(), nullable=True, comment='成功数'), sa.Column('fail_count', sa.Integer(), nullable=True, comment='失败数'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: running/success/partial/failed'), sa.Column('error_detail', sa.Text(), nullable=True, comment='失败详情'), sa.Column('started_at', sa.DateTime(), nullable=True, comment='开始时间'), sa.Column('finished_at', sa.DateTime(), nullable=True, comment='结束时间'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_wecom_sync_log_is_deleted'), 'core_wecom_sync_log', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_wecom_sync_log_status'), 'core_wecom_sync_log', ['status'], unique=False) op.create_index(op.f('ix_core_wecom_sync_log_sync_type'), 'core_wecom_sync_log', ['sync_type'], unique=False) op.create_index(op.f('ix_core_wecom_sync_log_sys_create_datetime'), 'core_wecom_sync_log', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_wecom_sync_log_sys_creator_id'), 'core_wecom_sync_log', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_wecom_sync_log_sys_dept_id'), 'core_wecom_sync_log', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_wecom_sync_log_sys_update_datetime'), 'core_wecom_sync_log', ['sys_update_datetime'], unique=False) op.create_table('demos', sa.Column('title', sa.String(length=100), nullable=False, comment='标题'), sa.Column('content', sa.Text(), nullable=True, comment='内容'), sa.Column('status', sa.Integer(), nullable=True, comment='状态:0=草稿,1=发布,2=归档'), sa.Column('priority', sa.Integer(), nullable=True, comment='优先级:0=低,1=中,2=高'), sa.Column('is_active', sa.Boolean(), nullable=True, comment='是否激活'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_demos_is_deleted'), 'demos', ['is_deleted'], unique=False) op.create_index(op.f('ix_demos_sys_create_datetime'), 'demos', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_demos_sys_creator_id'), 'demos', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_demos_sys_dept_id'), 'demos', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_demos_sys_update_datetime'), 'demos', ['sys_update_datetime'], unique=False) op.create_table('document_template', sa.Column('application_id', sa.String(length=21), nullable=True, comment='所属应用ID'), sa.Column('name', sa.String(length=100), nullable=False, comment='模板名称'), sa.Column('code', sa.String(length=100), nullable=False, comment='模板编码'), sa.Column('category', sa.String(length=50), nullable=True, comment='分类: leave/expense/purchase/contract/certificate/other'), sa.Column('description', sa.Text(), nullable=True, comment='描述'), sa.Column('form_code', sa.String(length=100), nullable=True, comment='关联表单编码'), sa.Column('workflow_code', sa.String(length=100), nullable=True, comment='关联流程编码'), sa.Column('template_type', sa.String(length=20), nullable=True, comment='模板类型: designer/html'), sa.Column('template_content', sa.Text(), nullable=True, comment='模板内容(JSON或HTML)'), sa.Column('template_css', sa.Text(), nullable=True, comment='自定义CSS'), sa.Column('page_size', sa.String(length=20), nullable=True, comment='页面大小: A4/A3/Letter/Legal'), sa.Column('page_orientation', sa.String(length=20), nullable=True, comment='页面方向: portrait/landscape'), sa.Column('page_margin', sa.JSON(), nullable=True, comment='页边距(mm)'), sa.Column('watermark_enabled', sa.Boolean(), nullable=True, comment='是否启用水印'), sa.Column('watermark_text', sa.String(length=100), nullable=True, comment='水印文字'), sa.Column('watermark_type', sa.String(length=20), nullable=True, comment='水印类型: text/image'), sa.Column('watermark_image_id', sa.String(length=36), nullable=True, comment='水印图片文件ID'), sa.Column('watermark_opacity', sa.Integer(), nullable=True, comment='水印透明度(0-100)'), sa.Column('watermark_angle', sa.Integer(), nullable=True, comment='水印角度'), sa.Column('seal_enabled', sa.Boolean(), nullable=True, comment='是否启用签章'), sa.Column('seal_positions', sa.JSON(), nullable=True, comment='签章位置配置'), sa.Column('header_enabled', sa.Boolean(), nullable=True, comment='是否启用页眉'), sa.Column('header_template', sa.Text(), nullable=True, comment='页眉模板'), sa.Column('footer_enabled', sa.Boolean(), nullable=True, comment='是否启用页脚'), sa.Column('footer_template', sa.Text(), nullable=True, comment='页脚模板'), sa.Column('show_page_number', sa.Boolean(), nullable=True, comment='是否显示页码'), sa.Column('calculation_rules', sa.JSON(), nullable=True, comment='计算规则配置'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: draft/published'), sa.Column('is_builtin', sa.Boolean(), nullable=True, comment='是否内置模板'), sa.Column('version', sa.Integer(), nullable=True, comment='版本号'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('code') ) op.create_index(op.f('ix_document_template_application_id'), 'document_template', ['application_id'], unique=False) op.create_index('ix_document_template_code', 'document_template', ['code'], unique=False) op.create_index(op.f('ix_document_template_form_code'), 'document_template', ['form_code'], unique=False) op.create_index(op.f('ix_document_template_is_deleted'), 'document_template', ['is_deleted'], unique=False) op.create_index(op.f('ix_document_template_status'), 'document_template', ['status'], unique=False) op.create_index(op.f('ix_document_template_sys_create_datetime'), 'document_template', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_document_template_sys_creator_id'), 'document_template', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_document_template_sys_dept_id'), 'document_template', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_document_template_sys_update_datetime'), 'document_template', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_document_template_workflow_code'), 'document_template', ['workflow_code'], unique=False) op.create_table('electronic_seal', sa.Column('name', sa.String(length=100), nullable=False, comment='签章名称'), sa.Column('seal_type', sa.String(length=20), nullable=False, comment='类型: company/department/personal/contract/finance'), sa.Column('description', sa.Text(), nullable=True, comment='描述'), sa.Column('seal_image_id', sa.String(length=36), nullable=False, comment='签章图片文件ID'), sa.Column('owner_type', sa.String(length=20), nullable=True, comment='所有者类型: all/dept/role/user'), sa.Column('owner_ids', sa.JSON(), nullable=True, comment='所有者ID列表'), sa.Column('scope', sa.String(length=20), nullable=True, comment='使用范围: all/specific'), sa.Column('allowed_template_ids', sa.JSON(), nullable=True, comment='允许使用的模板ID列表'), sa.Column('width', sa.Integer(), nullable=True, comment='宽度(像素)'), sa.Column('height', sa.Integer(), nullable=True, comment='高度(像素)'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: active/disabled'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_electronic_seal_is_deleted'), 'electronic_seal', ['is_deleted'], unique=False) op.create_index('ix_electronic_seal_seal_type', 'electronic_seal', ['seal_type'], unique=False) op.create_index('ix_electronic_seal_status', 'electronic_seal', ['status'], unique=False) op.create_index(op.f('ix_electronic_seal_sys_create_datetime'), 'electronic_seal', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_electronic_seal_sys_creator_id'), 'electronic_seal', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_electronic_seal_sys_dept_id'), 'electronic_seal', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_electronic_seal_sys_update_datetime'), 'electronic_seal', ['sys_update_datetime'], unique=False) op.create_table('form_meta', sa.Column('application_id', sa.String(length=21), nullable=True, comment='所属应用ID'), sa.Column('name', sa.String(length=100), nullable=False, comment='表单名称'), sa.Column('code', sa.String(length=100), nullable=False, comment='表单编码'), sa.Column('form_type', sa.String(length=20), nullable=True, comment='表单类型: normal/workflow'), sa.Column('description', sa.Text(), nullable=True, comment='描述'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: draft/published'), sa.Column('version', sa.Integer(), nullable=True, comment='版本号'), sa.Column('db_config', sa.String(length=100), nullable=False, comment='数据库配置名'), sa.Column('main_table', sa.String(length=100), nullable=False, comment='主表名'), sa.Column('main_table_schema', sa.String(length=100), nullable=True, comment='主表Schema'), sa.Column('main_table_database', sa.String(length=100), nullable=True, comment='主表数据库'), sa.Column('show_in_mobile', sa.Boolean(), nullable=True, comment='是否在移动端显示'), sa.Column('icon', sa.String(length=100), nullable=True, comment='图标'), sa.Column('icon_bg_color', sa.String(length=200), nullable=True, comment='图标背景色'), sa.Column('form_config', sa.JSON(), nullable=True, comment='表单设计配置'), sa.Column('list_config', sa.JSON(), nullable=True, comment='列表设计配置'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('code') ) op.create_index(op.f('ix_form_meta_application_id'), 'form_meta', ['application_id'], unique=False) op.create_index(op.f('ix_form_meta_is_deleted'), 'form_meta', ['is_deleted'], unique=False) op.create_index(op.f('ix_form_meta_status'), 'form_meta', ['status'], unique=False) op.create_index(op.f('ix_form_meta_sys_create_datetime'), 'form_meta', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_form_meta_sys_creator_id'), 'form_meta', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_form_meta_sys_dept_id'), 'form_meta', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_form_meta_sys_update_datetime'), 'form_meta', ['sys_update_datetime'], unique=False) op.create_table('form_sub_table', sa.Column('form_id', sa.String(length=50), nullable=False, comment='所属表单ID'), sa.Column('table_name', sa.String(length=100), nullable=False, comment='从表名'), sa.Column('table_schema', sa.String(length=100), nullable=True, comment='从表Schema'), sa.Column('table_database', sa.String(length=100), nullable=True, comment='从表数据库'), sa.Column('alias', sa.String(length=100), nullable=True, comment='别名'), sa.Column('foreign_key', sa.String(length=100), nullable=False, comment='外键字段'), sa.Column('related_field', sa.String(length=100), nullable=True, comment='关联主表字段'), sa.Column('relation_type', sa.String(length=20), nullable=True, comment='关联类型: one-to-one/one-to-many'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_form_sub_table_form_id'), 'form_sub_table', ['form_id'], unique=False) op.create_index(op.f('ix_form_sub_table_is_deleted'), 'form_sub_table', ['is_deleted'], unique=False) op.create_index(op.f('ix_form_sub_table_sys_create_datetime'), 'form_sub_table', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_form_sub_table_sys_creator_id'), 'form_sub_table', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_form_sub_table_sys_dept_id'), 'form_sub_table', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_form_sub_table_sys_update_datetime'), 'form_sub_table', ['sys_update_datetime'], unique=False) op.create_table('generated_document', sa.Column('template_id', sa.String(length=36), nullable=False, comment='模板ID'), sa.Column('template_code', sa.String(length=100), nullable=True, comment='模板编码'), sa.Column('template_name', sa.String(length=100), nullable=True, comment='模板名称'), sa.Column('form_code', sa.String(length=100), nullable=True, comment='表单编码'), sa.Column('form_data_id', sa.String(length=36), nullable=True, comment='表单数据ID'), sa.Column('workflow_code', sa.String(length=100), nullable=True, comment='流程编码'), sa.Column('instance_id', sa.String(length=36), nullable=True, comment='流程实例ID'), sa.Column('document_name', sa.String(length=200), nullable=False, comment='文档名称'), sa.Column('document_no', sa.String(length=100), nullable=True, comment='文档编号'), sa.Column('file_id', sa.String(length=36), nullable=False, comment='文件ID(关联file_manager)'), sa.Column('file_size', sa.BigInteger(), nullable=True, comment='文件大小(字节)'), sa.Column('page_count', sa.Integer(), nullable=True, comment='页数'), sa.Column('generate_type', sa.String(length=20), nullable=True, comment='生成方式: auto/manual'), sa.Column('generator_id', sa.String(length=36), nullable=True, comment='生成人ID'), sa.Column('generator_name', sa.String(length=100), nullable=True, comment='生成人姓名'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: generated/sealed/downloaded/printed'), sa.Column('download_count', sa.Integer(), nullable=True, comment='下载次数'), sa.Column('sealed', sa.Boolean(), nullable=True, comment='是否已盖章'), sa.Column('seal_info', sa.JSON(), nullable=True, comment='签章信息'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_generated_document_form_code'), 'generated_document', ['form_code'], unique=False) op.create_index('ix_generated_document_form_data_id', 'generated_document', ['form_data_id'], unique=False) op.create_index(op.f('ix_generated_document_instance_id'), 'generated_document', ['instance_id'], unique=False) op.create_index(op.f('ix_generated_document_is_deleted'), 'generated_document', ['is_deleted'], unique=False) op.create_index(op.f('ix_generated_document_sys_create_datetime'), 'generated_document', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_generated_document_sys_creator_id'), 'generated_document', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_generated_document_sys_dept_id'), 'generated_document', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_generated_document_sys_update_datetime'), 'generated_document', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_generated_document_template_id'), 'generated_document', ['template_id'], unique=False) op.create_table('page_meta', sa.Column('application_id', sa.String(length=21), nullable=True, comment='所属应用ID'), sa.Column('name', sa.String(length=100), nullable=False, comment='页面名称'), sa.Column('code', sa.String(length=100), nullable=False, comment='页面编码'), sa.Column('category', sa.String(length=50), nullable=True, comment='分类'), sa.Column('description', sa.Text(), nullable=True, comment='描述'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: draft/published'), sa.Column('version', sa.Integer(), nullable=True, comment='版本号'), sa.Column('page_config', sa.JSON(), nullable=True, comment='页面设计配置'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('code') ) op.create_index(op.f('ix_page_meta_application_id'), 'page_meta', ['application_id'], unique=False) op.create_index(op.f('ix_page_meta_is_deleted'), 'page_meta', ['is_deleted'], unique=False) op.create_index(op.f('ix_page_meta_status'), 'page_meta', ['status'], unique=False) op.create_index(op.f('ix_page_meta_sys_create_datetime'), 'page_meta', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_page_meta_sys_creator_id'), 'page_meta', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_page_meta_sys_dept_id'), 'page_meta', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_page_meta_sys_update_datetime'), 'page_meta', ['sys_update_datetime'], unique=False) op.create_table('screen_material', sa.Column('category_id', sa.String(length=32), nullable=True, comment='分类ID'), sa.Column('name', sa.String(length=100), nullable=False, comment='素材名称'), sa.Column('file_id', sa.String(length=32), nullable=True, comment='文件ID(关联文件管理器)'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_screen_material_category_id'), 'screen_material', ['category_id'], unique=False) op.create_index(op.f('ix_screen_material_is_deleted'), 'screen_material', ['is_deleted'], unique=False) op.create_index(op.f('ix_screen_material_sys_create_datetime'), 'screen_material', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_screen_material_sys_creator_id'), 'screen_material', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_screen_material_sys_dept_id'), 'screen_material', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_screen_material_sys_update_datetime'), 'screen_material', ['sys_update_datetime'], unique=False) op.create_table('screen_material_category', sa.Column('name', sa.String(length=50), nullable=False, comment='分类名称'), sa.Column('code', sa.String(length=50), nullable=False, comment='分类编码'), sa.Column('icon', sa.String(length=50), nullable=True, comment='图标名称'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_screen_material_category_code'), 'screen_material_category', ['code'], unique=True) op.create_index(op.f('ix_screen_material_category_is_deleted'), 'screen_material_category', ['is_deleted'], unique=False) op.create_index(op.f('ix_screen_material_category_sys_create_datetime'), 'screen_material_category', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_screen_material_category_sys_creator_id'), 'screen_material_category', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_screen_material_category_sys_dept_id'), 'screen_material_category', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_screen_material_category_sys_update_datetime'), 'screen_material_category', ['sys_update_datetime'], unique=False) op.create_table('screen_project', sa.Column('application_id', sa.String(length=21), nullable=True, comment='所属应用ID'), sa.Column('name', sa.String(length=100), nullable=False, comment='项目名称'), sa.Column('code', sa.String(length=100), nullable=False, comment='项目编码'), sa.Column('description', sa.Text(), nullable=True, comment='项目描述'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: draft/published'), sa.Column('version', sa.Integer(), nullable=True, comment='版本号'), sa.Column('thumbnail', sa.Text(), nullable=True, comment='缩略图(Base64或URL)'), sa.Column('screen_config', sa.JSON(), nullable=True, comment='大屏设计配置'), sa.Column('access_password', sa.String(length=100), nullable=True, comment='访问密码'), sa.Column('published_at', sa.DateTime(), nullable=True, comment='发布时间'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_screen_project_application_id'), 'screen_project', ['application_id'], unique=False) op.create_index(op.f('ix_screen_project_code'), 'screen_project', ['code'], unique=True) op.create_index(op.f('ix_screen_project_is_deleted'), 'screen_project', ['is_deleted'], unique=False) op.create_index(op.f('ix_screen_project_sys_create_datetime'), 'screen_project', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_screen_project_sys_creator_id'), 'screen_project', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_screen_project_sys_dept_id'), 'screen_project', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_screen_project_sys_update_datetime'), 'screen_project', ['sys_update_datetime'], unique=False) op.create_table('seal_usage_log', sa.Column('seal_id', sa.String(length=36), nullable=False, comment='签章ID'), sa.Column('seal_name', sa.String(length=100), nullable=True, comment='签章名称'), sa.Column('document_id', sa.String(length=36), nullable=False, comment='文档ID'), sa.Column('document_name', sa.String(length=200), nullable=True, comment='文档名称'), sa.Column('user_id', sa.String(length=36), nullable=False, comment='使用人ID'), sa.Column('user_name', sa.String(length=100), nullable=True, comment='使用人姓名'), sa.Column('position_x', sa.Integer(), nullable=True, comment='X坐标'), sa.Column('position_y', sa.Integer(), nullable=True, comment='Y坐标'), sa.Column('page_number', sa.Integer(), nullable=True, comment='页码'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('ix_seal_usage_log_document_id', 'seal_usage_log', ['document_id'], unique=False) op.create_index(op.f('ix_seal_usage_log_is_deleted'), 'seal_usage_log', ['is_deleted'], unique=False) op.create_index(op.f('ix_seal_usage_log_seal_id'), 'seal_usage_log', ['seal_id'], unique=False) op.create_index(op.f('ix_seal_usage_log_sys_create_datetime'), 'seal_usage_log', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_seal_usage_log_sys_creator_id'), 'seal_usage_log', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_seal_usage_log_sys_dept_id'), 'seal_usage_log', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_seal_usage_log_sys_update_datetime'), 'seal_usage_log', ['sys_update_datetime'], unique=False) op.create_table('smart_document_template', sa.Column('name', sa.String(length=200), nullable=False, comment='模板名称'), sa.Column('description', sa.Text(), nullable=True, comment='模板描述'), sa.Column('icon', sa.String(length=50), nullable=True, comment='模板图标'), sa.Column('category', sa.String(length=50), nullable=True, comment='分类: system / custom'), sa.Column('content', sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), 'postgresql'), nullable=False, comment='模板内容(Tiptap JSON)'), sa.Column('preview_image', sa.String(length=500), nullable=True, comment='预览图URL'), sa.Column('is_system', sa.Boolean(), nullable=True, comment='是否系统预设模板'), sa.Column('use_count', sa.Integer(), nullable=True, comment='使用次数'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_smart_document_template_is_deleted'), 'smart_document_template', ['is_deleted'], unique=False) op.create_index(op.f('ix_smart_document_template_sys_create_datetime'), 'smart_document_template', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_smart_document_template_sys_creator_id'), 'smart_document_template', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_smart_document_template_sys_dept_id'), 'smart_document_template', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_smart_document_template_sys_update_datetime'), 'smart_document_template', ['sys_update_datetime'], unique=False) op.create_table('smart_document_version', sa.Column('document_id', sa.String(length=21), nullable=False, comment='文档ID(逻辑外键关联smart_table)'), sa.Column('version', sa.Integer(), nullable=False, comment='版本号'), sa.Column('content', sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), 'postgresql'), nullable=False, comment='文档内容快照(Tiptap JSON)'), sa.Column('title', sa.String(length=200), nullable=True, comment='版本标题/文档名称快照'), sa.Column('change_summary', sa.String(length=500), nullable=True, comment='变更摘要'), sa.Column('content_size', sa.Integer(), nullable=True, comment='内容大小(字节)'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('ix_doc_version_doc_created', 'smart_document_version', ['document_id', 'sys_create_datetime'], unique=False) op.create_index('ix_doc_version_doc_ver', 'smart_document_version', ['document_id', 'version'], unique=False) op.create_index(op.f('ix_smart_document_version_document_id'), 'smart_document_version', ['document_id'], unique=False) op.create_index(op.f('ix_smart_document_version_is_deleted'), 'smart_document_version', ['is_deleted'], unique=False) op.create_index(op.f('ix_smart_document_version_sys_create_datetime'), 'smart_document_version', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_smart_document_version_sys_creator_id'), 'smart_document_version', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_smart_document_version_sys_dept_id'), 'smart_document_version', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_smart_document_version_sys_update_datetime'), 'smart_document_version', ['sys_update_datetime'], unique=False) op.create_table('smart_field', sa.Column('table_id', sa.String(length=21), nullable=False, comment='所属表ID'), sa.Column('name', sa.String(length=200), nullable=False, comment='字段名'), sa.Column('type', sa.String(length=30), nullable=False, comment='字段类型'), sa.Column('width', sa.Integer(), nullable=True, comment='列宽'), sa.Column('visible', sa.Boolean(), nullable=True, comment='是否可见'), sa.Column('required', sa.Boolean(), nullable=True, comment='是否必填'), sa.Column('description', sa.Text(), nullable=True, comment='描述'), sa.Column('config', sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), 'postgresql'), nullable=True, comment='扩展配置(options/format/precision等)'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_smart_field_is_deleted'), 'smart_field', ['is_deleted'], unique=False) op.create_index(op.f('ix_smart_field_sys_create_datetime'), 'smart_field', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_smart_field_sys_creator_id'), 'smart_field', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_smart_field_sys_dept_id'), 'smart_field', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_smart_field_sys_update_datetime'), 'smart_field', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_smart_field_table_id'), 'smart_field', ['table_id'], unique=False) op.create_index('ix_smart_field_table_sort', 'smart_field', ['table_id', 'sort'], unique=False) op.create_table('smart_record', sa.Column('table_id', sa.String(length=21), nullable=False, comment='所属表ID'), sa.Column('values', sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), 'postgresql'), nullable=True, comment='字段值映射 {fieldId: cellValue}'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_smart_record_is_deleted'), 'smart_record', ['is_deleted'], unique=False) op.create_index(op.f('ix_smart_record_sys_create_datetime'), 'smart_record', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_smart_record_sys_creator_id'), 'smart_record', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_smart_record_sys_dept_id'), 'smart_record', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_smart_record_sys_update_datetime'), 'smart_record', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_smart_record_table_id'), 'smart_record', ['table_id'], unique=False) op.create_index('ix_smart_record_table_sort', 'smart_record', ['table_id', 'sort'], unique=False) op.create_table('smart_table', sa.Column('name', sa.String(length=200), nullable=False, comment='表名'), sa.Column('icon', sa.String(length=50), nullable=True, comment='图标'), sa.Column('description', sa.Text(), nullable=True, comment='描述'), sa.Column('active_view_id', sa.String(length=21), nullable=True, comment='当前激活视图ID'), sa.Column('type', sa.String(length=20), nullable=False, comment='类型: table / document'), sa.Column('content', sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), 'postgresql'), nullable=True, comment='文档内容(Tiptap JSON), 仅 type=document 时使用'), sa.Column('parent_id', sa.String(length=21), nullable=True, comment='父页面ID(自引用,用于子页面层级嵌套)'), sa.Column('wiki_space_id', sa.String(length=21), nullable=True, comment='所属文档库ID'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_smart_table_is_deleted'), 'smart_table', ['is_deleted'], unique=False) op.create_index(op.f('ix_smart_table_parent_id'), 'smart_table', ['parent_id'], unique=False) op.create_index(op.f('ix_smart_table_sys_create_datetime'), 'smart_table', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_smart_table_sys_creator_id'), 'smart_table', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_smart_table_sys_dept_id'), 'smart_table', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_smart_table_sys_update_datetime'), 'smart_table', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_smart_table_wiki_space_id'), 'smart_table', ['wiki_space_id'], unique=False) op.create_table('smart_table_collaborator', sa.Column('table_id', sa.String(length=21), nullable=False, comment='所属表ID'), sa.Column('subject_type', sa.String(length=20), nullable=False, comment='授权对象类型: user/dept/role'), sa.Column('subject_id', sa.String(length=21), nullable=False, comment='授权对象ID(用户/部门/角色)'), sa.Column('role_id', sa.String(length=21), nullable=False, comment='表角色ID'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('ix_smart_collab_table_subject', 'smart_table_collaborator', ['table_id', 'subject_type', 'subject_id'], unique=True) op.create_index(op.f('ix_smart_table_collaborator_is_deleted'), 'smart_table_collaborator', ['is_deleted'], unique=False) op.create_index(op.f('ix_smart_table_collaborator_role_id'), 'smart_table_collaborator', ['role_id'], unique=False) op.create_index(op.f('ix_smart_table_collaborator_subject_id'), 'smart_table_collaborator', ['subject_id'], unique=False) op.create_index(op.f('ix_smart_table_collaborator_sys_create_datetime'), 'smart_table_collaborator', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_smart_table_collaborator_sys_creator_id'), 'smart_table_collaborator', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_smart_table_collaborator_sys_dept_id'), 'smart_table_collaborator', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_smart_table_collaborator_sys_update_datetime'), 'smart_table_collaborator', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_smart_table_collaborator_table_id'), 'smart_table_collaborator', ['table_id'], unique=False) op.create_table('smart_table_comment', sa.Column('record_id', sa.String(length=21), nullable=False, comment='所属记录ID'), sa.Column('user_id', sa.String(length=21), nullable=False, comment='评论者用户ID'), sa.Column('content', sa.Text(), nullable=False, comment='评论内容(纯文本,含@提及标记)'), sa.Column('mentions', sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), 'postgresql'), nullable=True, comment='被@提及的用户ID列表'), sa.Column('parent_id', sa.String(length=21), nullable=True, comment='父评论ID(用于回复)'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('ix_comment_record_created', 'smart_table_comment', ['record_id', 'sys_create_datetime'], unique=False) op.create_index(op.f('ix_smart_table_comment_is_deleted'), 'smart_table_comment', ['is_deleted'], unique=False) op.create_index(op.f('ix_smart_table_comment_parent_id'), 'smart_table_comment', ['parent_id'], unique=False) op.create_index(op.f('ix_smart_table_comment_record_id'), 'smart_table_comment', ['record_id'], unique=False) op.create_index(op.f('ix_smart_table_comment_sys_create_datetime'), 'smart_table_comment', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_smart_table_comment_sys_creator_id'), 'smart_table_comment', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_smart_table_comment_sys_dept_id'), 'smart_table_comment', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_smart_table_comment_sys_update_datetime'), 'smart_table_comment', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_smart_table_comment_user_id'), 'smart_table_comment', ['user_id'], unique=False) op.create_table('smart_table_field_perm', sa.Column('table_id', sa.String(length=21), nullable=False, comment='所属表ID'), sa.Column('role_id', sa.String(length=21), nullable=False, comment='表角色ID'), sa.Column('field_id', sa.String(length=21), nullable=False, comment='字段ID'), sa.Column('access', sa.String(length=10), nullable=True, comment='访问级别: write/read/hidden'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('ix_smart_fperm_role_field', 'smart_table_field_perm', ['table_id', 'role_id', 'field_id'], unique=True) op.create_index(op.f('ix_smart_table_field_perm_field_id'), 'smart_table_field_perm', ['field_id'], unique=False) op.create_index(op.f('ix_smart_table_field_perm_is_deleted'), 'smart_table_field_perm', ['is_deleted'], unique=False) op.create_index(op.f('ix_smart_table_field_perm_role_id'), 'smart_table_field_perm', ['role_id'], unique=False) op.create_index(op.f('ix_smart_table_field_perm_sys_create_datetime'), 'smart_table_field_perm', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_smart_table_field_perm_sys_creator_id'), 'smart_table_field_perm', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_smart_table_field_perm_sys_dept_id'), 'smart_table_field_perm', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_smart_table_field_perm_sys_update_datetime'), 'smart_table_field_perm', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_smart_table_field_perm_table_id'), 'smart_table_field_perm', ['table_id'], unique=False) op.create_table('smart_table_link', sa.Column('field_id', sa.String(length=21), nullable=False, comment='Link字段ID'), sa.Column('source_record_id', sa.String(length=21), nullable=False, comment='源记录ID'), sa.Column('target_record_id', sa.String(length=21), nullable=False, comment='目标记录ID'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('ix_link_field_source', 'smart_table_link', ['field_id', 'source_record_id'], unique=False) op.create_index('ix_link_field_target', 'smart_table_link', ['field_id', 'target_record_id'], unique=False) op.create_index(op.f('ix_smart_table_link_field_id'), 'smart_table_link', ['field_id'], unique=False) op.create_index(op.f('ix_smart_table_link_is_deleted'), 'smart_table_link', ['is_deleted'], unique=False) op.create_index(op.f('ix_smart_table_link_source_record_id'), 'smart_table_link', ['source_record_id'], unique=False) op.create_index(op.f('ix_smart_table_link_sys_create_datetime'), 'smart_table_link', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_smart_table_link_sys_creator_id'), 'smart_table_link', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_smart_table_link_sys_dept_id'), 'smart_table_link', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_smart_table_link_sys_update_datetime'), 'smart_table_link', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_smart_table_link_target_record_id'), 'smart_table_link', ['target_record_id'], unique=False) op.create_index('uq_link_pair', 'smart_table_link', ['field_id', 'source_record_id', 'target_record_id'], unique=True) op.create_table('smart_table_role', sa.Column('table_id', sa.String(length=21), nullable=True, comment='所属表ID(null=系统预置)'), sa.Column('name', sa.String(length=64), nullable=False, comment='角色名称'), sa.Column('role_type', sa.String(length=20), nullable=False, comment='owner/manager/editor/viewer/custom'), sa.Column('capabilities', sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), 'postgresql'), nullable=True, comment='能力配置JSON'), sa.Column('is_system', sa.Boolean(), nullable=True, comment='是否系统预置(不可删除)'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_smart_table_role_is_deleted'), 'smart_table_role', ['is_deleted'], unique=False) op.create_index(op.f('ix_smart_table_role_sys_create_datetime'), 'smart_table_role', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_smart_table_role_sys_creator_id'), 'smart_table_role', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_smart_table_role_sys_dept_id'), 'smart_table_role', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_smart_table_role_sys_update_datetime'), 'smart_table_role', ['sys_update_datetime'], unique=False) op.create_index('ix_smart_table_role_table', 'smart_table_role', ['table_id', 'role_type'], unique=False) op.create_index(op.f('ix_smart_table_role_table_id'), 'smart_table_role', ['table_id'], unique=False) op.create_table('smart_table_row_rule', sa.Column('table_id', sa.String(length=21), nullable=False, comment='所属表ID'), sa.Column('role_id', sa.String(length=21), nullable=False, comment='表角色ID'), sa.Column('rule_type', sa.String(length=10), nullable=False, comment='规则类型: view/edit'), sa.Column('mode', sa.String(length=20), nullable=True, comment='模式: all/conditions/creator_only'), sa.Column('conditions', sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), 'postgresql'), nullable=True, comment='过滤条件(复用视图filter结构)'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('ix_smart_row_rule_role_type', 'smart_table_row_rule', ['table_id', 'role_id', 'rule_type'], unique=True) op.create_index(op.f('ix_smart_table_row_rule_is_deleted'), 'smart_table_row_rule', ['is_deleted'], unique=False) op.create_index(op.f('ix_smart_table_row_rule_role_id'), 'smart_table_row_rule', ['role_id'], unique=False) op.create_index(op.f('ix_smart_table_row_rule_sys_create_datetime'), 'smart_table_row_rule', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_smart_table_row_rule_sys_creator_id'), 'smart_table_row_rule', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_smart_table_row_rule_sys_dept_id'), 'smart_table_row_rule', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_smart_table_row_rule_sys_update_datetime'), 'smart_table_row_rule', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_smart_table_row_rule_table_id'), 'smart_table_row_rule', ['table_id'], unique=False) op.create_table('smart_view', sa.Column('table_id', sa.String(length=21), nullable=False, comment='所属表ID'), sa.Column('name', sa.String(length=200), nullable=False, comment='视图名'), sa.Column('type', sa.String(length=30), nullable=True, comment='视图类型'), sa.Column('config', sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), 'postgresql'), nullable=True, comment='视图配置(filters/sorts/groups/visibleFieldIds等)'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_smart_view_is_deleted'), 'smart_view', ['is_deleted'], unique=False) op.create_index(op.f('ix_smart_view_sys_create_datetime'), 'smart_view', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_smart_view_sys_creator_id'), 'smart_view', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_smart_view_sys_dept_id'), 'smart_view', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_smart_view_sys_update_datetime'), 'smart_view', ['sys_update_datetime'], unique=False) op.create_index(op.f('ix_smart_view_table_id'), 'smart_view', ['table_id'], unique=False) op.create_index('ix_smart_view_table_sort', 'smart_view', ['table_id', 'sort'], unique=False) op.create_table('smart_wiki_space', sa.Column('name', sa.String(length=200), nullable=False, comment='文档库名称'), sa.Column('icon', sa.String(length=50), nullable=True, comment='图标'), sa.Column('avatar', sa.String(length=500), nullable=True, comment='头像文件ID'), sa.Column('description', sa.Text(), nullable=True, comment='描述'), sa.Column('cover', sa.String(length=500), nullable=True, comment='封面图URL'), sa.Column('category', sa.String(length=50), nullable=True, comment='分类标签'), sa.Column('visibility', sa.String(length=20), nullable=True, comment='可见性: private/team/public'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_smart_wiki_space_is_deleted'), 'smart_wiki_space', ['is_deleted'], unique=False) op.create_index(op.f('ix_smart_wiki_space_sys_create_datetime'), 'smart_wiki_space', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_smart_wiki_space_sys_creator_id'), 'smart_wiki_space', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_smart_wiki_space_sys_dept_id'), 'smart_wiki_space', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_smart_wiki_space_sys_update_datetime'), 'smart_wiki_space', ['sys_update_datetime'], unique=False) op.create_table('sys_role_resource_field_permission_config', sa.Column('role_id', sa.String(length=50), nullable=False, comment='角色ID'), sa.Column('resource_type', sa.String(length=100), nullable=False, comment='资源类型'), sa.Column('field_name', sa.String(length=100), nullable=False, comment='字段名称'), sa.Column('permission_type', sa.String(length=20), nullable=False, comment='权限类型: read/write/hidden/masked'), sa.Column('mask_rule', sa.String(length=50), nullable=True, comment='脱敏规则: phone/email/id_card/name'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('idx_role_resource', 'sys_role_resource_field_permission_config', ['role_id', 'resource_type'], unique=False) op.create_index('idx_role_resource_field', 'sys_role_resource_field_permission_config', ['role_id', 'resource_type', 'field_name'], unique=True) op.create_index(op.f('ix_sys_role_resource_field_permission_config_is_deleted'), 'sys_role_resource_field_permission_config', ['is_deleted'], unique=False) op.create_index(op.f('ix_sys_role_resource_field_permission_config_sys_create_datetime'), 'sys_role_resource_field_permission_config', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_sys_role_resource_field_permission_config_sys_creator_id'), 'sys_role_resource_field_permission_config', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_sys_role_resource_field_permission_config_sys_dept_id'), 'sys_role_resource_field_permission_config', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_sys_role_resource_field_permission_config_sys_update_datetime'), 'sys_role_resource_field_permission_config', ['sys_update_datetime'], unique=False) op.create_table('workflow_definition', sa.Column('application_id', sa.String(length=21), nullable=True, comment='所属应用ID'), sa.Column('name', sa.String(length=100), nullable=False, comment='流程名称'), sa.Column('code', sa.String(length=100), nullable=False, comment='流程编码'), sa.Column('workflow_type', sa.String(length=20), nullable=True, comment='流程类型: approval/application/business/hr/finance/admin/other'), sa.Column('icon', sa.String(length=100), nullable=True, comment='流程图标'), sa.Column('icon_bg_color', sa.String(length=200), nullable=True, comment='图标背景色(支持渐变色)'), sa.Column('category', sa.String(length=50), nullable=True, comment='分类'), sa.Column('description', sa.Text(), nullable=True, comment='描述'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: draft/published/disabled'), sa.Column('version', sa.Integer(), nullable=True, comment='版本号'), sa.Column('form_code', sa.String(length=100), nullable=False, comment='关联表单编码'), sa.Column('form_name', sa.String(length=100), nullable=True, comment='关联表单名称'), sa.Column('document_template_codes', sa.JSON(), nullable=True, comment='关联文档模板编码列表'), sa.Column('flow_definition', sa.JSON(), nullable=True, comment='流程定义'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('code') ) op.create_index(op.f('ix_workflow_definition_application_id'), 'workflow_definition', ['application_id'], unique=False) op.create_index('ix_workflow_definition_code', 'workflow_definition', ['code'], unique=False) op.create_index('ix_workflow_definition_form_code', 'workflow_definition', ['form_code'], unique=False) op.create_index(op.f('ix_workflow_definition_is_deleted'), 'workflow_definition', ['is_deleted'], unique=False) op.create_index('ix_workflow_definition_status', 'workflow_definition', ['status'], unique=False) op.create_index(op.f('ix_workflow_definition_sys_create_datetime'), 'workflow_definition', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_workflow_definition_sys_creator_id'), 'workflow_definition', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_workflow_definition_sys_dept_id'), 'workflow_definition', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_workflow_definition_sys_update_datetime'), 'workflow_definition', ['sys_update_datetime'], unique=False) op.create_index('ix_workflow_definition_workflow_type', 'workflow_definition', ['workflow_type'], unique=False) op.create_table('workflow_instance', sa.Column('workflow_id', sa.String(length=36), nullable=False, comment='流程定义ID'), sa.Column('instance_no', sa.String(length=50), nullable=False, comment='流程实例编号'), sa.Column('title', sa.String(length=200), nullable=False, comment='流程标题'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: pending/approved/rejected/canceled'), sa.Column('initiator_id', sa.String(length=36), nullable=False, comment='发起人ID'), sa.Column('form_code', sa.String(length=100), nullable=False, comment='表单编码'), sa.Column('form_data_id', sa.String(length=36), nullable=False, comment='表单数据ID'), sa.Column('current_node_id', sa.String(length=50), nullable=True, comment='当前节点ID'), sa.Column('current_node_name', sa.String(length=100), nullable=True, comment='当前节点名称'), sa.Column('parallel_branch_status', sa.JSON(), nullable=True, comment='并行分支状态'), sa.Column('is_subflow', sa.Boolean(), nullable=True, comment='是否为子流程'), sa.Column('parent_instance_id', sa.String(length=36), nullable=True, comment='父流程实例ID'), sa.Column('parent_node_id', sa.String(length=50), nullable=True, comment='父流程等待节点ID'), sa.Column('subflow_timeout', sa.Integer(), nullable=True, comment='子流程超时时间(秒)'), sa.Column('subflow_timeout_action', sa.String(length=20), nullable=True, comment='超时操作: skip/reject'), sa.Column('delay_node_id', sa.String(length=50), nullable=True, comment='延时等待的节点ID'), sa.Column('delay_until', sa.DateTime(), nullable=True, comment='延时到期时间'), sa.Column('started_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='发起时间'), sa.Column('completed_at', sa.DateTime(), nullable=True, comment='完成时间'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('instance_no') ) op.create_index('ix_workflow_instance_initiator_id', 'workflow_instance', ['initiator_id'], unique=False) op.create_index('ix_workflow_instance_instance_no', 'workflow_instance', ['instance_no'], unique=False) op.create_index(op.f('ix_workflow_instance_is_deleted'), 'workflow_instance', ['is_deleted'], unique=False) op.create_index('ix_workflow_instance_status', 'workflow_instance', ['status'], unique=False) op.create_index(op.f('ix_workflow_instance_sys_create_datetime'), 'workflow_instance', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_workflow_instance_sys_creator_id'), 'workflow_instance', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_workflow_instance_sys_dept_id'), 'workflow_instance', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_workflow_instance_sys_update_datetime'), 'workflow_instance', ['sys_update_datetime'], unique=False) op.create_index('ix_workflow_instance_workflow_id', 'workflow_instance', ['workflow_id'], unique=False) op.create_table('workflow_log', sa.Column('instance_id', sa.String(length=36), nullable=False, comment='流程实例ID'), sa.Column('node_id', sa.String(length=50), nullable=True, comment='节点ID'), sa.Column('node_name', sa.String(length=100), nullable=True, comment='节点名称'), sa.Column('action', sa.String(length=30), nullable=False, comment='操作类型'), sa.Column('operator_id', sa.String(length=36), nullable=False, comment='操作人ID'), sa.Column('comment', sa.Text(), nullable=True, comment='备注/意见'), sa.Column('extra_data', sa.JSON(), nullable=True, comment='额外数据'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('ix_workflow_log_instance_id', 'workflow_log', ['instance_id'], unique=False) op.create_index(op.f('ix_workflow_log_is_deleted'), 'workflow_log', ['is_deleted'], unique=False) op.create_index('ix_workflow_log_operator_id', 'workflow_log', ['operator_id'], unique=False) op.create_index(op.f('ix_workflow_log_sys_create_datetime'), 'workflow_log', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_workflow_log_sys_creator_id'), 'workflow_log', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_workflow_log_sys_dept_id'), 'workflow_log', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_workflow_log_sys_update_datetime'), 'workflow_log', ['sys_update_datetime'], unique=False) op.create_table('workflow_task', sa.Column('instance_id', sa.String(length=36), nullable=False, comment='流程实例ID'), sa.Column('node_id', sa.String(length=50), nullable=False, comment='节点ID'), sa.Column('node_name', sa.String(length=100), nullable=False, comment='节点名称'), sa.Column('task_type', sa.String(length=20), nullable=True, comment='任务类型: approval/handle/copy/revise'), sa.Column('status', sa.String(length=20), nullable=True, comment='状态: pending/waiting/approved/rejected/returned/transferred/delegated/handled/canceled/read'), sa.Column('assignee_id', sa.String(length=36), nullable=False, comment='处理人ID'), sa.Column('comment', sa.Text(), nullable=True, comment='审批意见'), sa.Column('signature_file_id', sa.String(length=36), nullable=True, comment='签名文件ID'), sa.Column('handled_at', sa.DateTime(), nullable=True, comment='处理时间'), sa.Column('transferred_to_id', sa.String(length=36), nullable=True, comment='转交给用户ID'), sa.Column('parent_task_id', sa.String(length=50), nullable=True, comment='父任务ID(委派/加签时记录原任务)'), sa.Column('sign_type', sa.String(length=20), nullable=True, comment='加签类型: before/after/parallel/delegate/transfer'), sa.Column('timeout_at', sa.DateTime(), nullable=True, comment='超时时间'), sa.Column('timeout_action', sa.String(length=20), nullable=True, comment='超时操作: notify/auto_approve/auto_reject'), sa.Column('timeout_notified', sa.Boolean(), nullable=True, comment='是否已发送超时通知'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.PrimaryKeyConstraint('id') ) op.create_index('ix_workflow_task_assignee_id', 'workflow_task', ['assignee_id'], unique=False) op.create_index('ix_workflow_task_assignee_status', 'workflow_task', ['assignee_id', 'status'], unique=False) op.create_index('ix_workflow_task_instance_id', 'workflow_task', ['instance_id'], unique=False) op.create_index('ix_workflow_task_instance_status', 'workflow_task', ['instance_id', 'status'], unique=False) op.create_index(op.f('ix_workflow_task_is_deleted'), 'workflow_task', ['is_deleted'], unique=False) op.create_index('ix_workflow_task_status', 'workflow_task', ['status'], unique=False) op.create_index(op.f('ix_workflow_task_sys_create_datetime'), 'workflow_task', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_workflow_task_sys_creator_id'), 'workflow_task', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_workflow_task_sys_dept_id'), 'workflow_task', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_workflow_task_sys_update_datetime'), 'workflow_task', ['sys_update_datetime'], unique=False) op.create_table('core_city', sa.Column('code', sa.String(length=20), nullable=False, comment='城市代码'), sa.Column('name', sa.String(length=100), nullable=False, comment='城市名称'), sa.Column('province_code', sa.String(length=20), nullable=False, comment='省份代码'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.ForeignKeyConstraint(['province_code'], ['core_province.code'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_city_code'), 'core_city', ['code'], unique=True) op.create_index(op.f('ix_core_city_is_deleted'), 'core_city', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_city_sys_create_datetime'), 'core_city', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_city_sys_creator_id'), 'core_city', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_city_sys_dept_id'), 'core_city', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_city_sys_update_datetime'), 'core_city', ['sys_update_datetime'], unique=False) op.create_table('core_role_dept', sa.Column('role_id', sa.String(length=21), nullable=False), sa.Column('dept_id', sa.String(length=21), nullable=False), sa.ForeignKeyConstraint(['dept_id'], ['core_dept.id'], ondelete='CASCADE'), sa.ForeignKeyConstraint(['role_id'], ['core_role.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('role_id', 'dept_id') ) op.create_table('core_role_menu', sa.Column('role_id', sa.String(length=21), nullable=False), sa.Column('menu_id', sa.String(length=21), nullable=False), sa.ForeignKeyConstraint(['menu_id'], ['core_menu.id'], ondelete='CASCADE'), sa.ForeignKeyConstraint(['role_id'], ['core_role.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('role_id', 'menu_id') ) op.create_table('core_role_permission', sa.Column('role_id', sa.String(length=21), nullable=False), sa.Column('permission_id', sa.String(length=21), nullable=False), sa.ForeignKeyConstraint(['permission_id'], ['core_permission.id'], ondelete='CASCADE'), sa.ForeignKeyConstraint(['role_id'], ['core_role.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('role_id', 'permission_id') ) op.create_table('core_area', sa.Column('code', sa.String(length=20), nullable=False, comment='区县代码'), sa.Column('name', sa.String(length=100), nullable=False, comment='区县名称'), sa.Column('province_code', sa.String(length=20), nullable=False, comment='省份代码'), sa.Column('city_code', sa.String(length=20), nullable=False, comment='城市代码'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.ForeignKeyConstraint(['city_code'], ['core_city.code'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_area_code'), 'core_area', ['code'], unique=True) op.create_index(op.f('ix_core_area_is_deleted'), 'core_area', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_area_province_code'), 'core_area', ['province_code'], unique=False) op.create_index(op.f('ix_core_area_sys_create_datetime'), 'core_area', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_area_sys_creator_id'), 'core_area', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_area_sys_dept_id'), 'core_area', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_area_sys_update_datetime'), 'core_area', ['sys_update_datetime'], unique=False) op.create_table('core_street', sa.Column('code', sa.String(length=20), nullable=False, comment='街道代码'), sa.Column('name', sa.String(length=100), nullable=False, comment='街道名称'), sa.Column('province_code', sa.String(length=20), nullable=False, comment='省份代码'), sa.Column('city_code', sa.String(length=20), nullable=False, comment='城市代码'), sa.Column('area_code', sa.String(length=20), nullable=False, comment='区县代码'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.ForeignKeyConstraint(['area_code'], ['core_area.code'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_street_city_code'), 'core_street', ['city_code'], unique=False) op.create_index(op.f('ix_core_street_code'), 'core_street', ['code'], unique=True) op.create_index(op.f('ix_core_street_is_deleted'), 'core_street', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_street_province_code'), 'core_street', ['province_code'], unique=False) op.create_index(op.f('ix_core_street_sys_create_datetime'), 'core_street', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_street_sys_creator_id'), 'core_street', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_street_sys_dept_id'), 'core_street', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_street_sys_update_datetime'), 'core_street', ['sys_update_datetime'], unique=False) op.create_table('core_village', sa.Column('code', sa.String(length=20), nullable=False, comment='村庄代码'), sa.Column('name', sa.String(length=100), nullable=False, comment='村庄名称'), sa.Column('province_code', sa.String(length=20), nullable=False, comment='省份代码'), sa.Column('city_code', sa.String(length=20), nullable=False, comment='城市代码'), sa.Column('area_code', sa.String(length=20), nullable=False, comment='区县代码'), sa.Column('street_code', sa.String(length=20), nullable=False, comment='街道代码'), sa.Column('sort', sa.Integer(), nullable=True, comment='排序'), sa.Column('id', sa.String(length=21), nullable=False, comment='主键ID(NanoId)'), sa.Column('is_deleted', sa.Boolean(), nullable=True, comment='是否删除'), sa.Column('sys_create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='创建时间'), sa.Column('sys_update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=True, comment='更新时间'), sa.Column('sys_creator_id', sa.String(length=21), nullable=True, comment='创建人ID(逻辑外键关联core_user)'), sa.Column('sys_modifier_id', sa.String(length=21), nullable=True, comment='修改人ID(逻辑外键关联core_user)'), sa.Column('sys_dept_id', sa.String(length=21), nullable=True, comment='部门ID(逻辑外键关联core_dept)'), sa.ForeignKeyConstraint(['street_code'], ['core_street.code'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_core_village_area_code'), 'core_village', ['area_code'], unique=False) op.create_index(op.f('ix_core_village_city_code'), 'core_village', ['city_code'], unique=False) op.create_index(op.f('ix_core_village_code'), 'core_village', ['code'], unique=True) op.create_index(op.f('ix_core_village_is_deleted'), 'core_village', ['is_deleted'], unique=False) op.create_index(op.f('ix_core_village_province_code'), 'core_village', ['province_code'], unique=False) op.create_index(op.f('ix_core_village_sys_create_datetime'), 'core_village', ['sys_create_datetime'], unique=False) op.create_index(op.f('ix_core_village_sys_creator_id'), 'core_village', ['sys_creator_id'], unique=False) op.create_index(op.f('ix_core_village_sys_dept_id'), 'core_village', ['sys_dept_id'], unique=False) op.create_index(op.f('ix_core_village_sys_update_datetime'), 'core_village', ['sys_update_datetime'], unique=False) # ### end Alembic commands ### def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.drop_index(op.f('ix_core_village_sys_update_datetime'), table_name='core_village') op.drop_index(op.f('ix_core_village_sys_dept_id'), table_name='core_village') op.drop_index(op.f('ix_core_village_sys_creator_id'), table_name='core_village') op.drop_index(op.f('ix_core_village_sys_create_datetime'), table_name='core_village') op.drop_index(op.f('ix_core_village_province_code'), table_name='core_village') op.drop_index(op.f('ix_core_village_is_deleted'), table_name='core_village') op.drop_index(op.f('ix_core_village_code'), table_name='core_village') op.drop_index(op.f('ix_core_village_city_code'), table_name='core_village') op.drop_index(op.f('ix_core_village_area_code'), table_name='core_village') op.drop_table('core_village') op.drop_index(op.f('ix_core_street_sys_update_datetime'), table_name='core_street') op.drop_index(op.f('ix_core_street_sys_dept_id'), table_name='core_street') op.drop_index(op.f('ix_core_street_sys_creator_id'), table_name='core_street') op.drop_index(op.f('ix_core_street_sys_create_datetime'), table_name='core_street') op.drop_index(op.f('ix_core_street_province_code'), table_name='core_street') op.drop_index(op.f('ix_core_street_is_deleted'), table_name='core_street') op.drop_index(op.f('ix_core_street_code'), table_name='core_street') op.drop_index(op.f('ix_core_street_city_code'), table_name='core_street') op.drop_table('core_street') op.drop_index(op.f('ix_core_area_sys_update_datetime'), table_name='core_area') op.drop_index(op.f('ix_core_area_sys_dept_id'), table_name='core_area') op.drop_index(op.f('ix_core_area_sys_creator_id'), table_name='core_area') op.drop_index(op.f('ix_core_area_sys_create_datetime'), table_name='core_area') op.drop_index(op.f('ix_core_area_province_code'), table_name='core_area') op.drop_index(op.f('ix_core_area_is_deleted'), table_name='core_area') op.drop_index(op.f('ix_core_area_code'), table_name='core_area') op.drop_table('core_area') op.drop_table('core_role_permission') op.drop_table('core_role_menu') op.drop_table('core_role_dept') op.drop_index(op.f('ix_core_city_sys_update_datetime'), table_name='core_city') op.drop_index(op.f('ix_core_city_sys_dept_id'), table_name='core_city') op.drop_index(op.f('ix_core_city_sys_creator_id'), table_name='core_city') op.drop_index(op.f('ix_core_city_sys_create_datetime'), table_name='core_city') op.drop_index(op.f('ix_core_city_is_deleted'), table_name='core_city') op.drop_index(op.f('ix_core_city_code'), table_name='core_city') op.drop_table('core_city') op.drop_index(op.f('ix_workflow_task_sys_update_datetime'), table_name='workflow_task') op.drop_index(op.f('ix_workflow_task_sys_dept_id'), table_name='workflow_task') op.drop_index(op.f('ix_workflow_task_sys_creator_id'), table_name='workflow_task') op.drop_index(op.f('ix_workflow_task_sys_create_datetime'), table_name='workflow_task') op.drop_index('ix_workflow_task_status', table_name='workflow_task') op.drop_index(op.f('ix_workflow_task_is_deleted'), table_name='workflow_task') op.drop_index('ix_workflow_task_instance_status', table_name='workflow_task') op.drop_index('ix_workflow_task_instance_id', table_name='workflow_task') op.drop_index('ix_workflow_task_assignee_status', table_name='workflow_task') op.drop_index('ix_workflow_task_assignee_id', table_name='workflow_task') op.drop_table('workflow_task') op.drop_index(op.f('ix_workflow_log_sys_update_datetime'), table_name='workflow_log') op.drop_index(op.f('ix_workflow_log_sys_dept_id'), table_name='workflow_log') op.drop_index(op.f('ix_workflow_log_sys_creator_id'), table_name='workflow_log') op.drop_index(op.f('ix_workflow_log_sys_create_datetime'), table_name='workflow_log') op.drop_index('ix_workflow_log_operator_id', table_name='workflow_log') op.drop_index(op.f('ix_workflow_log_is_deleted'), table_name='workflow_log') op.drop_index('ix_workflow_log_instance_id', table_name='workflow_log') op.drop_table('workflow_log') op.drop_index('ix_workflow_instance_workflow_id', table_name='workflow_instance') op.drop_index(op.f('ix_workflow_instance_sys_update_datetime'), table_name='workflow_instance') op.drop_index(op.f('ix_workflow_instance_sys_dept_id'), table_name='workflow_instance') op.drop_index(op.f('ix_workflow_instance_sys_creator_id'), table_name='workflow_instance') op.drop_index(op.f('ix_workflow_instance_sys_create_datetime'), table_name='workflow_instance') op.drop_index('ix_workflow_instance_status', table_name='workflow_instance') op.drop_index(op.f('ix_workflow_instance_is_deleted'), table_name='workflow_instance') op.drop_index('ix_workflow_instance_instance_no', table_name='workflow_instance') op.drop_index('ix_workflow_instance_initiator_id', table_name='workflow_instance') op.drop_table('workflow_instance') op.drop_index('ix_workflow_definition_workflow_type', table_name='workflow_definition') op.drop_index(op.f('ix_workflow_definition_sys_update_datetime'), table_name='workflow_definition') op.drop_index(op.f('ix_workflow_definition_sys_dept_id'), table_name='workflow_definition') op.drop_index(op.f('ix_workflow_definition_sys_creator_id'), table_name='workflow_definition') op.drop_index(op.f('ix_workflow_definition_sys_create_datetime'), table_name='workflow_definition') op.drop_index('ix_workflow_definition_status', table_name='workflow_definition') op.drop_index(op.f('ix_workflow_definition_is_deleted'), table_name='workflow_definition') op.drop_index('ix_workflow_definition_form_code', table_name='workflow_definition') op.drop_index('ix_workflow_definition_code', table_name='workflow_definition') op.drop_index(op.f('ix_workflow_definition_application_id'), table_name='workflow_definition') op.drop_table('workflow_definition') op.drop_index(op.f('ix_sys_role_resource_field_permission_config_sys_update_datetime'), table_name='sys_role_resource_field_permission_config') op.drop_index(op.f('ix_sys_role_resource_field_permission_config_sys_dept_id'), table_name='sys_role_resource_field_permission_config') op.drop_index(op.f('ix_sys_role_resource_field_permission_config_sys_creator_id'), table_name='sys_role_resource_field_permission_config') op.drop_index(op.f('ix_sys_role_resource_field_permission_config_sys_create_datetime'), table_name='sys_role_resource_field_permission_config') op.drop_index(op.f('ix_sys_role_resource_field_permission_config_is_deleted'), table_name='sys_role_resource_field_permission_config') op.drop_index('idx_role_resource_field', table_name='sys_role_resource_field_permission_config') op.drop_index('idx_role_resource', table_name='sys_role_resource_field_permission_config') op.drop_table('sys_role_resource_field_permission_config') op.drop_index(op.f('ix_smart_wiki_space_sys_update_datetime'), table_name='smart_wiki_space') op.drop_index(op.f('ix_smart_wiki_space_sys_dept_id'), table_name='smart_wiki_space') op.drop_index(op.f('ix_smart_wiki_space_sys_creator_id'), table_name='smart_wiki_space') op.drop_index(op.f('ix_smart_wiki_space_sys_create_datetime'), table_name='smart_wiki_space') op.drop_index(op.f('ix_smart_wiki_space_is_deleted'), table_name='smart_wiki_space') op.drop_table('smart_wiki_space') op.drop_index('ix_smart_view_table_sort', table_name='smart_view') op.drop_index(op.f('ix_smart_view_table_id'), table_name='smart_view') op.drop_index(op.f('ix_smart_view_sys_update_datetime'), table_name='smart_view') op.drop_index(op.f('ix_smart_view_sys_dept_id'), table_name='smart_view') op.drop_index(op.f('ix_smart_view_sys_creator_id'), table_name='smart_view') op.drop_index(op.f('ix_smart_view_sys_create_datetime'), table_name='smart_view') op.drop_index(op.f('ix_smart_view_is_deleted'), table_name='smart_view') op.drop_table('smart_view') op.drop_index(op.f('ix_smart_table_row_rule_table_id'), table_name='smart_table_row_rule') op.drop_index(op.f('ix_smart_table_row_rule_sys_update_datetime'), table_name='smart_table_row_rule') op.drop_index(op.f('ix_smart_table_row_rule_sys_dept_id'), table_name='smart_table_row_rule') op.drop_index(op.f('ix_smart_table_row_rule_sys_creator_id'), table_name='smart_table_row_rule') op.drop_index(op.f('ix_smart_table_row_rule_sys_create_datetime'), table_name='smart_table_row_rule') op.drop_index(op.f('ix_smart_table_row_rule_role_id'), table_name='smart_table_row_rule') op.drop_index(op.f('ix_smart_table_row_rule_is_deleted'), table_name='smart_table_row_rule') op.drop_index('ix_smart_row_rule_role_type', table_name='smart_table_row_rule') op.drop_table('smart_table_row_rule') op.drop_index(op.f('ix_smart_table_role_table_id'), table_name='smart_table_role') op.drop_index('ix_smart_table_role_table', table_name='smart_table_role') op.drop_index(op.f('ix_smart_table_role_sys_update_datetime'), table_name='smart_table_role') op.drop_index(op.f('ix_smart_table_role_sys_dept_id'), table_name='smart_table_role') op.drop_index(op.f('ix_smart_table_role_sys_creator_id'), table_name='smart_table_role') op.drop_index(op.f('ix_smart_table_role_sys_create_datetime'), table_name='smart_table_role') op.drop_index(op.f('ix_smart_table_role_is_deleted'), table_name='smart_table_role') op.drop_table('smart_table_role') op.drop_index('uq_link_pair', table_name='smart_table_link') op.drop_index(op.f('ix_smart_table_link_target_record_id'), table_name='smart_table_link') op.drop_index(op.f('ix_smart_table_link_sys_update_datetime'), table_name='smart_table_link') op.drop_index(op.f('ix_smart_table_link_sys_dept_id'), table_name='smart_table_link') op.drop_index(op.f('ix_smart_table_link_sys_creator_id'), table_name='smart_table_link') op.drop_index(op.f('ix_smart_table_link_sys_create_datetime'), table_name='smart_table_link') op.drop_index(op.f('ix_smart_table_link_source_record_id'), table_name='smart_table_link') op.drop_index(op.f('ix_smart_table_link_is_deleted'), table_name='smart_table_link') op.drop_index(op.f('ix_smart_table_link_field_id'), table_name='smart_table_link') op.drop_index('ix_link_field_target', table_name='smart_table_link') op.drop_index('ix_link_field_source', table_name='smart_table_link') op.drop_table('smart_table_link') op.drop_index(op.f('ix_smart_table_field_perm_table_id'), table_name='smart_table_field_perm') op.drop_index(op.f('ix_smart_table_field_perm_sys_update_datetime'), table_name='smart_table_field_perm') op.drop_index(op.f('ix_smart_table_field_perm_sys_dept_id'), table_name='smart_table_field_perm') op.drop_index(op.f('ix_smart_table_field_perm_sys_creator_id'), table_name='smart_table_field_perm') op.drop_index(op.f('ix_smart_table_field_perm_sys_create_datetime'), table_name='smart_table_field_perm') op.drop_index(op.f('ix_smart_table_field_perm_role_id'), table_name='smart_table_field_perm') op.drop_index(op.f('ix_smart_table_field_perm_is_deleted'), table_name='smart_table_field_perm') op.drop_index(op.f('ix_smart_table_field_perm_field_id'), table_name='smart_table_field_perm') op.drop_index('ix_smart_fperm_role_field', table_name='smart_table_field_perm') op.drop_table('smart_table_field_perm') op.drop_index(op.f('ix_smart_table_comment_user_id'), table_name='smart_table_comment') op.drop_index(op.f('ix_smart_table_comment_sys_update_datetime'), table_name='smart_table_comment') op.drop_index(op.f('ix_smart_table_comment_sys_dept_id'), table_name='smart_table_comment') op.drop_index(op.f('ix_smart_table_comment_sys_creator_id'), table_name='smart_table_comment') op.drop_index(op.f('ix_smart_table_comment_sys_create_datetime'), table_name='smart_table_comment') op.drop_index(op.f('ix_smart_table_comment_record_id'), table_name='smart_table_comment') op.drop_index(op.f('ix_smart_table_comment_parent_id'), table_name='smart_table_comment') op.drop_index(op.f('ix_smart_table_comment_is_deleted'), table_name='smart_table_comment') op.drop_index('ix_comment_record_created', table_name='smart_table_comment') op.drop_table('smart_table_comment') op.drop_index(op.f('ix_smart_table_collaborator_table_id'), table_name='smart_table_collaborator') op.drop_index(op.f('ix_smart_table_collaborator_sys_update_datetime'), table_name='smart_table_collaborator') op.drop_index(op.f('ix_smart_table_collaborator_sys_dept_id'), table_name='smart_table_collaborator') op.drop_index(op.f('ix_smart_table_collaborator_sys_creator_id'), table_name='smart_table_collaborator') op.drop_index(op.f('ix_smart_table_collaborator_sys_create_datetime'), table_name='smart_table_collaborator') op.drop_index(op.f('ix_smart_table_collaborator_subject_id'), table_name='smart_table_collaborator') op.drop_index(op.f('ix_smart_table_collaborator_role_id'), table_name='smart_table_collaborator') op.drop_index(op.f('ix_smart_table_collaborator_is_deleted'), table_name='smart_table_collaborator') op.drop_index('ix_smart_collab_table_subject', table_name='smart_table_collaborator') op.drop_table('smart_table_collaborator') op.drop_index(op.f('ix_smart_table_wiki_space_id'), table_name='smart_table') op.drop_index(op.f('ix_smart_table_sys_update_datetime'), table_name='smart_table') op.drop_index(op.f('ix_smart_table_sys_dept_id'), table_name='smart_table') op.drop_index(op.f('ix_smart_table_sys_creator_id'), table_name='smart_table') op.drop_index(op.f('ix_smart_table_sys_create_datetime'), table_name='smart_table') op.drop_index(op.f('ix_smart_table_parent_id'), table_name='smart_table') op.drop_index(op.f('ix_smart_table_is_deleted'), table_name='smart_table') op.drop_table('smart_table') op.drop_index('ix_smart_record_table_sort', table_name='smart_record') op.drop_index(op.f('ix_smart_record_table_id'), table_name='smart_record') op.drop_index(op.f('ix_smart_record_sys_update_datetime'), table_name='smart_record') op.drop_index(op.f('ix_smart_record_sys_dept_id'), table_name='smart_record') op.drop_index(op.f('ix_smart_record_sys_creator_id'), table_name='smart_record') op.drop_index(op.f('ix_smart_record_sys_create_datetime'), table_name='smart_record') op.drop_index(op.f('ix_smart_record_is_deleted'), table_name='smart_record') op.drop_table('smart_record') op.drop_index('ix_smart_field_table_sort', table_name='smart_field') op.drop_index(op.f('ix_smart_field_table_id'), table_name='smart_field') op.drop_index(op.f('ix_smart_field_sys_update_datetime'), table_name='smart_field') op.drop_index(op.f('ix_smart_field_sys_dept_id'), table_name='smart_field') op.drop_index(op.f('ix_smart_field_sys_creator_id'), table_name='smart_field') op.drop_index(op.f('ix_smart_field_sys_create_datetime'), table_name='smart_field') op.drop_index(op.f('ix_smart_field_is_deleted'), table_name='smart_field') op.drop_table('smart_field') op.drop_index(op.f('ix_smart_document_version_sys_update_datetime'), table_name='smart_document_version') op.drop_index(op.f('ix_smart_document_version_sys_dept_id'), table_name='smart_document_version') op.drop_index(op.f('ix_smart_document_version_sys_creator_id'), table_name='smart_document_version') op.drop_index(op.f('ix_smart_document_version_sys_create_datetime'), table_name='smart_document_version') op.drop_index(op.f('ix_smart_document_version_is_deleted'), table_name='smart_document_version') op.drop_index(op.f('ix_smart_document_version_document_id'), table_name='smart_document_version') op.drop_index('ix_doc_version_doc_ver', table_name='smart_document_version') op.drop_index('ix_doc_version_doc_created', table_name='smart_document_version') op.drop_table('smart_document_version') op.drop_index(op.f('ix_smart_document_template_sys_update_datetime'), table_name='smart_document_template') op.drop_index(op.f('ix_smart_document_template_sys_dept_id'), table_name='smart_document_template') op.drop_index(op.f('ix_smart_document_template_sys_creator_id'), table_name='smart_document_template') op.drop_index(op.f('ix_smart_document_template_sys_create_datetime'), table_name='smart_document_template') op.drop_index(op.f('ix_smart_document_template_is_deleted'), table_name='smart_document_template') op.drop_table('smart_document_template') op.drop_index(op.f('ix_seal_usage_log_sys_update_datetime'), table_name='seal_usage_log') op.drop_index(op.f('ix_seal_usage_log_sys_dept_id'), table_name='seal_usage_log') op.drop_index(op.f('ix_seal_usage_log_sys_creator_id'), table_name='seal_usage_log') op.drop_index(op.f('ix_seal_usage_log_sys_create_datetime'), table_name='seal_usage_log') op.drop_index(op.f('ix_seal_usage_log_seal_id'), table_name='seal_usage_log') op.drop_index(op.f('ix_seal_usage_log_is_deleted'), table_name='seal_usage_log') op.drop_index('ix_seal_usage_log_document_id', table_name='seal_usage_log') op.drop_table('seal_usage_log') op.drop_index(op.f('ix_screen_project_sys_update_datetime'), table_name='screen_project') op.drop_index(op.f('ix_screen_project_sys_dept_id'), table_name='screen_project') op.drop_index(op.f('ix_screen_project_sys_creator_id'), table_name='screen_project') op.drop_index(op.f('ix_screen_project_sys_create_datetime'), table_name='screen_project') op.drop_index(op.f('ix_screen_project_is_deleted'), table_name='screen_project') op.drop_index(op.f('ix_screen_project_code'), table_name='screen_project') op.drop_index(op.f('ix_screen_project_application_id'), table_name='screen_project') op.drop_table('screen_project') op.drop_index(op.f('ix_screen_material_category_sys_update_datetime'), table_name='screen_material_category') op.drop_index(op.f('ix_screen_material_category_sys_dept_id'), table_name='screen_material_category') op.drop_index(op.f('ix_screen_material_category_sys_creator_id'), table_name='screen_material_category') op.drop_index(op.f('ix_screen_material_category_sys_create_datetime'), table_name='screen_material_category') op.drop_index(op.f('ix_screen_material_category_is_deleted'), table_name='screen_material_category') op.drop_index(op.f('ix_screen_material_category_code'), table_name='screen_material_category') op.drop_table('screen_material_category') op.drop_index(op.f('ix_screen_material_sys_update_datetime'), table_name='screen_material') op.drop_index(op.f('ix_screen_material_sys_dept_id'), table_name='screen_material') op.drop_index(op.f('ix_screen_material_sys_creator_id'), table_name='screen_material') op.drop_index(op.f('ix_screen_material_sys_create_datetime'), table_name='screen_material') op.drop_index(op.f('ix_screen_material_is_deleted'), table_name='screen_material') op.drop_index(op.f('ix_screen_material_category_id'), table_name='screen_material') op.drop_table('screen_material') op.drop_index(op.f('ix_page_meta_sys_update_datetime'), table_name='page_meta') op.drop_index(op.f('ix_page_meta_sys_dept_id'), table_name='page_meta') op.drop_index(op.f('ix_page_meta_sys_creator_id'), table_name='page_meta') op.drop_index(op.f('ix_page_meta_sys_create_datetime'), table_name='page_meta') op.drop_index(op.f('ix_page_meta_status'), table_name='page_meta') op.drop_index(op.f('ix_page_meta_is_deleted'), table_name='page_meta') op.drop_index(op.f('ix_page_meta_application_id'), table_name='page_meta') op.drop_table('page_meta') op.drop_index(op.f('ix_generated_document_template_id'), table_name='generated_document') op.drop_index(op.f('ix_generated_document_sys_update_datetime'), table_name='generated_document') op.drop_index(op.f('ix_generated_document_sys_dept_id'), table_name='generated_document') op.drop_index(op.f('ix_generated_document_sys_creator_id'), table_name='generated_document') op.drop_index(op.f('ix_generated_document_sys_create_datetime'), table_name='generated_document') op.drop_index(op.f('ix_generated_document_is_deleted'), table_name='generated_document') op.drop_index(op.f('ix_generated_document_instance_id'), table_name='generated_document') op.drop_index('ix_generated_document_form_data_id', table_name='generated_document') op.drop_index(op.f('ix_generated_document_form_code'), table_name='generated_document') op.drop_table('generated_document') op.drop_index(op.f('ix_form_sub_table_sys_update_datetime'), table_name='form_sub_table') op.drop_index(op.f('ix_form_sub_table_sys_dept_id'), table_name='form_sub_table') op.drop_index(op.f('ix_form_sub_table_sys_creator_id'), table_name='form_sub_table') op.drop_index(op.f('ix_form_sub_table_sys_create_datetime'), table_name='form_sub_table') op.drop_index(op.f('ix_form_sub_table_is_deleted'), table_name='form_sub_table') op.drop_index(op.f('ix_form_sub_table_form_id'), table_name='form_sub_table') op.drop_table('form_sub_table') op.drop_index(op.f('ix_form_meta_sys_update_datetime'), table_name='form_meta') op.drop_index(op.f('ix_form_meta_sys_dept_id'), table_name='form_meta') op.drop_index(op.f('ix_form_meta_sys_creator_id'), table_name='form_meta') op.drop_index(op.f('ix_form_meta_sys_create_datetime'), table_name='form_meta') op.drop_index(op.f('ix_form_meta_status'), table_name='form_meta') op.drop_index(op.f('ix_form_meta_is_deleted'), table_name='form_meta') op.drop_index(op.f('ix_form_meta_application_id'), table_name='form_meta') op.drop_table('form_meta') op.drop_index(op.f('ix_electronic_seal_sys_update_datetime'), table_name='electronic_seal') op.drop_index(op.f('ix_electronic_seal_sys_dept_id'), table_name='electronic_seal') op.drop_index(op.f('ix_electronic_seal_sys_creator_id'), table_name='electronic_seal') op.drop_index(op.f('ix_electronic_seal_sys_create_datetime'), table_name='electronic_seal') op.drop_index('ix_electronic_seal_status', table_name='electronic_seal') op.drop_index('ix_electronic_seal_seal_type', table_name='electronic_seal') op.drop_index(op.f('ix_electronic_seal_is_deleted'), table_name='electronic_seal') op.drop_table('electronic_seal') op.drop_index(op.f('ix_document_template_workflow_code'), table_name='document_template') op.drop_index(op.f('ix_document_template_sys_update_datetime'), table_name='document_template') op.drop_index(op.f('ix_document_template_sys_dept_id'), table_name='document_template') op.drop_index(op.f('ix_document_template_sys_creator_id'), table_name='document_template') op.drop_index(op.f('ix_document_template_sys_create_datetime'), table_name='document_template') op.drop_index(op.f('ix_document_template_status'), table_name='document_template') op.drop_index(op.f('ix_document_template_is_deleted'), table_name='document_template') op.drop_index(op.f('ix_document_template_form_code'), table_name='document_template') op.drop_index('ix_document_template_code', table_name='document_template') op.drop_index(op.f('ix_document_template_application_id'), table_name='document_template') op.drop_table('document_template') op.drop_index(op.f('ix_demos_sys_update_datetime'), table_name='demos') op.drop_index(op.f('ix_demos_sys_dept_id'), table_name='demos') op.drop_index(op.f('ix_demos_sys_creator_id'), table_name='demos') op.drop_index(op.f('ix_demos_sys_create_datetime'), table_name='demos') op.drop_index(op.f('ix_demos_is_deleted'), table_name='demos') op.drop_table('demos') op.drop_index(op.f('ix_core_wecom_sync_log_sys_update_datetime'), table_name='core_wecom_sync_log') op.drop_index(op.f('ix_core_wecom_sync_log_sys_dept_id'), table_name='core_wecom_sync_log') op.drop_index(op.f('ix_core_wecom_sync_log_sys_creator_id'), table_name='core_wecom_sync_log') op.drop_index(op.f('ix_core_wecom_sync_log_sys_create_datetime'), table_name='core_wecom_sync_log') op.drop_index(op.f('ix_core_wecom_sync_log_sync_type'), table_name='core_wecom_sync_log') op.drop_index(op.f('ix_core_wecom_sync_log_status'), table_name='core_wecom_sync_log') op.drop_index(op.f('ix_core_wecom_sync_log_is_deleted'), table_name='core_wecom_sync_log') op.drop_table('core_wecom_sync_log') op.drop_index(op.f('ix_core_user_role_user_id'), table_name='core_user_role') op.drop_index(op.f('ix_core_user_role_sys_update_datetime'), table_name='core_user_role') op.drop_index(op.f('ix_core_user_role_sys_dept_id'), table_name='core_user_role') op.drop_index(op.f('ix_core_user_role_sys_creator_id'), table_name='core_user_role') op.drop_index(op.f('ix_core_user_role_sys_create_datetime'), table_name='core_user_role') op.drop_index(op.f('ix_core_user_role_role_id'), table_name='core_user_role') op.drop_index(op.f('ix_core_user_role_is_deleted'), table_name='core_user_role') op.drop_index('idx_user_role_unique', table_name='core_user_role') op.drop_table('core_user_role') op.drop_index(op.f('ix_core_user_wecom_userid'), table_name='core_user') op.drop_index(op.f('ix_core_user_wechat_unionid'), table_name='core_user') op.drop_index(op.f('ix_core_user_wechat_openid'), table_name='core_user') op.drop_index(op.f('ix_core_user_username'), table_name='core_user') op.drop_index(op.f('ix_core_user_user_type'), table_name='core_user') op.drop_index(op.f('ix_core_user_user_status'), table_name='core_user') op.drop_index(op.f('ix_core_user_sys_update_datetime'), table_name='core_user') op.drop_index(op.f('ix_core_user_sys_dept_id'), table_name='core_user') op.drop_index(op.f('ix_core_user_sys_creator_id'), table_name='core_user') op.drop_index(op.f('ix_core_user_sys_create_datetime'), table_name='core_user') op.drop_index(op.f('ix_core_user_role_id'), table_name='core_user') op.drop_index(op.f('ix_core_user_qq_id'), table_name='core_user') op.drop_index(op.f('ix_core_user_post_id'), table_name='core_user') op.drop_index(op.f('ix_core_user_oauth_provider'), table_name='core_user') op.drop_index(op.f('ix_core_user_name'), table_name='core_user') op.drop_index(op.f('ix_core_user_mobile'), table_name='core_user') op.drop_index(op.f('ix_core_user_microsoft_id'), table_name='core_user') op.drop_index(op.f('ix_core_user_last_login_type'), table_name='core_user') op.drop_index(op.f('ix_core_user_is_superuser'), table_name='core_user') op.drop_index(op.f('ix_core_user_is_deleted'), table_name='core_user') op.drop_index(op.f('ix_core_user_is_active'), table_name='core_user') op.drop_index(op.f('ix_core_user_google_id'), table_name='core_user') op.drop_index(op.f('ix_core_user_github_id'), table_name='core_user') op.drop_index(op.f('ix_core_user_gitee_id'), table_name='core_user') op.drop_index(op.f('ix_core_user_feishu_userid'), table_name='core_user') op.drop_index(op.f('ix_core_user_feishu_union_id'), table_name='core_user') op.drop_index(op.f('ix_core_user_email'), table_name='core_user') op.drop_index(op.f('ix_core_user_dingtalk_userid'), table_name='core_user') op.drop_index(op.f('ix_core_user_dingtalk_unionid'), table_name='core_user') op.drop_index(op.f('ix_core_user_dept_id'), table_name='core_user') op.drop_table('core_user') op.drop_index(op.f('ix_core_ui_config_sys_update_datetime'), table_name='core_ui_config') op.drop_index(op.f('ix_core_ui_config_sys_dept_id'), table_name='core_ui_config') op.drop_index(op.f('ix_core_ui_config_sys_creator_id'), table_name='core_ui_config') op.drop_index(op.f('ix_core_ui_config_sys_create_datetime'), table_name='core_ui_config') op.drop_index(op.f('ix_core_ui_config_status'), table_name='core_ui_config') op.drop_index(op.f('ix_core_ui_config_is_deleted'), table_name='core_ui_config') op.drop_index(op.f('ix_core_ui_config_config_type'), table_name='core_ui_config') op.drop_index(op.f('ix_core_ui_config_config_key'), table_name='core_ui_config') op.drop_index(op.f('ix_core_ui_config_application_id'), table_name='core_ui_config') op.drop_table('core_ui_config') op.drop_index(op.f('ix_core_system_config_sys_update_datetime'), table_name='core_system_config') op.drop_index(op.f('ix_core_system_config_sys_dept_id'), table_name='core_system_config') op.drop_index(op.f('ix_core_system_config_sys_creator_id'), table_name='core_system_config') op.drop_index(op.f('ix_core_system_config_sys_create_datetime'), table_name='core_system_config') op.drop_index(op.f('ix_core_system_config_status'), table_name='core_system_config') op.drop_index(op.f('ix_core_system_config_is_deleted'), table_name='core_system_config') op.drop_index(op.f('ix_core_system_config_config_key'), table_name='core_system_config') op.drop_index(op.f('ix_core_system_config_config_group'), table_name='core_system_config') op.drop_table('core_system_config') op.drop_index(op.f('ix_core_signature_token_token'), table_name='core_signature_token') op.drop_index(op.f('ix_core_signature_token_sys_update_datetime'), table_name='core_signature_token') op.drop_index(op.f('ix_core_signature_token_sys_dept_id'), table_name='core_signature_token') op.drop_index(op.f('ix_core_signature_token_sys_creator_id'), table_name='core_signature_token') op.drop_index(op.f('ix_core_signature_token_sys_create_datetime'), table_name='core_signature_token') op.drop_index(op.f('ix_core_signature_token_is_deleted'), table_name='core_signature_token') op.drop_table('core_signature_token') op.drop_index('ix_scheduler_log_status_start', table_name='core_scheduler_log') op.drop_index('ix_scheduler_log_job_status', table_name='core_scheduler_log') op.drop_index('ix_scheduler_log_code_start', table_name='core_scheduler_log') op.drop_index(op.f('ix_core_scheduler_log_sys_update_datetime'), table_name='core_scheduler_log') op.drop_index(op.f('ix_core_scheduler_log_sys_dept_id'), table_name='core_scheduler_log') op.drop_index(op.f('ix_core_scheduler_log_sys_creator_id'), table_name='core_scheduler_log') op.drop_index(op.f('ix_core_scheduler_log_sys_create_datetime'), table_name='core_scheduler_log') op.drop_index(op.f('ix_core_scheduler_log_status'), table_name='core_scheduler_log') op.drop_index(op.f('ix_core_scheduler_log_start_time'), table_name='core_scheduler_log') op.drop_index(op.f('ix_core_scheduler_log_job_name'), table_name='core_scheduler_log') op.drop_index(op.f('ix_core_scheduler_log_job_id'), table_name='core_scheduler_log') op.drop_index(op.f('ix_core_scheduler_log_job_code'), table_name='core_scheduler_log') op.drop_index(op.f('ix_core_scheduler_log_is_deleted'), table_name='core_scheduler_log') op.drop_table('core_scheduler_log') op.drop_index('ix_scheduler_job_status_trigger', table_name='core_scheduler_job') op.drop_index('ix_scheduler_job_priority_status', table_name='core_scheduler_job') op.drop_index('ix_scheduler_job_next_run_status', table_name='core_scheduler_job') op.drop_index('ix_scheduler_job_group_status', table_name='core_scheduler_job') op.drop_index(op.f('ix_core_scheduler_job_trigger_type'), table_name='core_scheduler_job') op.drop_index(op.f('ix_core_scheduler_job_sys_update_datetime'), table_name='core_scheduler_job') op.drop_index(op.f('ix_core_scheduler_job_sys_dept_id'), table_name='core_scheduler_job') op.drop_index(op.f('ix_core_scheduler_job_sys_creator_id'), table_name='core_scheduler_job') op.drop_index(op.f('ix_core_scheduler_job_sys_create_datetime'), table_name='core_scheduler_job') op.drop_index(op.f('ix_core_scheduler_job_status'), table_name='core_scheduler_job') op.drop_index(op.f('ix_core_scheduler_job_priority'), table_name='core_scheduler_job') op.drop_index(op.f('ix_core_scheduler_job_name'), table_name='core_scheduler_job') op.drop_index(op.f('ix_core_scheduler_job_is_deleted'), table_name='core_scheduler_job') op.drop_index(op.f('ix_core_scheduler_job_group'), table_name='core_scheduler_job') op.drop_index(op.f('ix_core_scheduler_job_code'), table_name='core_scheduler_job') op.drop_index(op.f('ix_core_scheduler_job_application_id'), table_name='core_scheduler_job') op.drop_table('core_scheduler_job') op.drop_index(op.f('ix_core_role_sys_update_datetime'), table_name='core_role') op.drop_index(op.f('ix_core_role_sys_dept_id'), table_name='core_role') op.drop_index(op.f('ix_core_role_sys_creator_id'), table_name='core_role') op.drop_index(op.f('ix_core_role_sys_create_datetime'), table_name='core_role') op.drop_index(op.f('ix_core_role_status'), table_name='core_role') op.drop_index(op.f('ix_core_role_role_type'), table_name='core_role') op.drop_index(op.f('ix_core_role_priority'), table_name='core_role') op.drop_index(op.f('ix_core_role_name'), table_name='core_role') op.drop_index(op.f('ix_core_role_is_deleted'), table_name='core_role') op.drop_index(op.f('ix_core_role_code'), table_name='core_role') op.drop_table('core_role') op.drop_index(op.f('ix_core_resource_data_scope_config_sys_update_datetime'), table_name='core_resource_data_scope_config') op.drop_index(op.f('ix_core_resource_data_scope_config_sys_dept_id'), table_name='core_resource_data_scope_config') op.drop_index(op.f('ix_core_resource_data_scope_config_sys_creator_id'), table_name='core_resource_data_scope_config') op.drop_index(op.f('ix_core_resource_data_scope_config_sys_create_datetime'), table_name='core_resource_data_scope_config') op.drop_index(op.f('ix_core_resource_data_scope_config_role_id'), table_name='core_resource_data_scope_config') op.drop_index(op.f('ix_core_resource_data_scope_config_resource_type'), table_name='core_resource_data_scope_config') op.drop_index(op.f('ix_core_resource_data_scope_config_is_deleted'), table_name='core_resource_data_scope_config') op.drop_table('core_resource_data_scope_config') op.drop_index(op.f('ix_core_province_sys_update_datetime'), table_name='core_province') op.drop_index(op.f('ix_core_province_sys_dept_id'), table_name='core_province') op.drop_index(op.f('ix_core_province_sys_creator_id'), table_name='core_province') op.drop_index(op.f('ix_core_province_sys_create_datetime'), table_name='core_province') op.drop_index(op.f('ix_core_province_is_deleted'), table_name='core_province') op.drop_index(op.f('ix_core_province_code'), table_name='core_province') op.drop_table('core_province') op.drop_index(op.f('ix_core_post_sys_update_datetime'), table_name='core_post') op.drop_index(op.f('ix_core_post_sys_dept_id'), table_name='core_post') op.drop_index(op.f('ix_core_post_sys_creator_id'), table_name='core_post') op.drop_index(op.f('ix_core_post_sys_create_datetime'), table_name='core_post') op.drop_index(op.f('ix_core_post_status'), table_name='core_post') op.drop_index(op.f('ix_core_post_post_type'), table_name='core_post') op.drop_index(op.f('ix_core_post_post_level'), table_name='core_post') op.drop_index(op.f('ix_core_post_name'), table_name='core_post') op.drop_index(op.f('ix_core_post_is_deleted'), table_name='core_post') op.drop_index(op.f('ix_core_post_dept_id'), table_name='core_post') op.drop_index(op.f('ix_core_post_code'), table_name='core_post') op.drop_table('core_post') op.drop_index(op.f('ix_core_permission_sys_update_datetime'), table_name='core_permission') op.drop_index(op.f('ix_core_permission_sys_dept_id'), table_name='core_permission') op.drop_index(op.f('ix_core_permission_sys_creator_id'), table_name='core_permission') op.drop_index(op.f('ix_core_permission_sys_create_datetime'), table_name='core_permission') op.drop_index(op.f('ix_core_permission_permission_type'), table_name='core_permission') op.drop_index(op.f('ix_core_permission_name'), table_name='core_permission') op.drop_index(op.f('ix_core_permission_menu_id'), table_name='core_permission') op.drop_index(op.f('ix_core_permission_is_deleted'), table_name='core_permission') op.drop_index(op.f('ix_core_permission_is_active'), table_name='core_permission') op.drop_index(op.f('ix_core_permission_code'), table_name='core_permission') op.drop_table('core_permission') op.drop_index('ix_message_recipient_type', table_name='core_message') op.drop_index('ix_message_recipient_status', table_name='core_message') op.drop_index(op.f('ix_core_message_sys_update_datetime'), table_name='core_message') op.drop_index(op.f('ix_core_message_sys_dept_id'), table_name='core_message') op.drop_index(op.f('ix_core_message_sys_creator_id'), table_name='core_message') op.drop_index(op.f('ix_core_message_sys_create_datetime'), table_name='core_message') op.drop_index(op.f('ix_core_message_status'), table_name='core_message') op.drop_index(op.f('ix_core_message_recipient_id'), table_name='core_message') op.drop_index(op.f('ix_core_message_msg_type'), table_name='core_message') op.drop_index(op.f('ix_core_message_is_deleted'), table_name='core_message') op.drop_table('core_message') op.drop_index(op.f('ix_core_menu_sys_update_datetime'), table_name='core_menu') op.drop_index(op.f('ix_core_menu_sys_dept_id'), table_name='core_menu') op.drop_index(op.f('ix_core_menu_sys_creator_id'), table_name='core_menu') op.drop_index(op.f('ix_core_menu_sys_create_datetime'), table_name='core_menu') op.drop_index(op.f('ix_core_menu_parent_id'), table_name='core_menu') op.drop_index(op.f('ix_core_menu_is_deleted'), table_name='core_menu') op.drop_index(op.f('ix_core_menu_application_id'), table_name='core_menu') op.drop_table('core_menu') op.drop_index('ix_login_log_username_status', table_name='core_login_log') op.drop_index('ix_login_log_user_type', table_name='core_login_log') op.drop_index('ix_login_log_user_datetime', table_name='core_login_log') op.drop_index('ix_login_log_type_datetime', table_name='core_login_log') op.drop_index('ix_login_log_status_datetime', table_name='core_login_log') op.drop_index('ix_login_log_ip_datetime', table_name='core_login_log') op.drop_index(op.f('ix_core_login_log_username'), table_name='core_login_log') op.drop_index(op.f('ix_core_login_log_user_id'), table_name='core_login_log') op.drop_index(op.f('ix_core_login_log_sys_update_datetime'), table_name='core_login_log') op.drop_index(op.f('ix_core_login_log_sys_dept_id'), table_name='core_login_log') op.drop_index(op.f('ix_core_login_log_sys_creator_id'), table_name='core_login_log') op.drop_index(op.f('ix_core_login_log_sys_create_datetime'), table_name='core_login_log') op.drop_index(op.f('ix_core_login_log_status'), table_name='core_login_log') op.drop_index(op.f('ix_core_login_log_login_type'), table_name='core_login_log') op.drop_index(op.f('ix_core_login_log_login_ip'), table_name='core_login_log') op.drop_index(op.f('ix_core_login_log_is_deleted'), table_name='core_login_log') op.drop_table('core_login_log') op.drop_index('ix_file_manager_storage_type', table_name='core_file_manager') op.drop_index('ix_file_manager_parent_type', table_name='core_file_manager') op.drop_index('ix_file_manager_md5', table_name='core_file_manager') op.drop_index(op.f('ix_core_file_manager_sys_update_datetime'), table_name='core_file_manager') op.drop_index(op.f('ix_core_file_manager_sys_dept_id'), table_name='core_file_manager') op.drop_index(op.f('ix_core_file_manager_sys_creator_id'), table_name='core_file_manager') op.drop_index(op.f('ix_core_file_manager_sys_create_datetime'), table_name='core_file_manager') op.drop_index(op.f('ix_core_file_manager_is_deleted'), table_name='core_file_manager') op.drop_table('core_file_manager') op.drop_index('ix_file_access_token_token', table_name='core_file_access_token') op.drop_index('ix_file_access_token_file_id', table_name='core_file_access_token') op.drop_index('ix_file_access_token_expires_at', table_name='core_file_access_token') op.drop_index(op.f('ix_core_file_access_token_sys_update_datetime'), table_name='core_file_access_token') op.drop_index(op.f('ix_core_file_access_token_sys_dept_id'), table_name='core_file_access_token') op.drop_index(op.f('ix_core_file_access_token_sys_creator_id'), table_name='core_file_access_token') op.drop_index(op.f('ix_core_file_access_token_sys_create_datetime'), table_name='core_file_access_token') op.drop_index(op.f('ix_core_file_access_token_is_deleted'), table_name='core_file_access_token') op.drop_table('core_file_access_token') op.drop_index(op.f('ix_core_feishu_sync_log_sys_update_datetime'), table_name='core_feishu_sync_log') op.drop_index(op.f('ix_core_feishu_sync_log_sys_dept_id'), table_name='core_feishu_sync_log') op.drop_index(op.f('ix_core_feishu_sync_log_sys_creator_id'), table_name='core_feishu_sync_log') op.drop_index(op.f('ix_core_feishu_sync_log_sys_create_datetime'), table_name='core_feishu_sync_log') op.drop_index(op.f('ix_core_feishu_sync_log_sync_type'), table_name='core_feishu_sync_log') op.drop_index(op.f('ix_core_feishu_sync_log_status'), table_name='core_feishu_sync_log') op.drop_index(op.f('ix_core_feishu_sync_log_is_deleted'), table_name='core_feishu_sync_log') op.drop_table('core_feishu_sync_log') op.drop_index(op.f('ix_core_dingtalk_sync_log_sys_update_datetime'), table_name='core_dingtalk_sync_log') op.drop_index(op.f('ix_core_dingtalk_sync_log_sys_dept_id'), table_name='core_dingtalk_sync_log') op.drop_index(op.f('ix_core_dingtalk_sync_log_sys_creator_id'), table_name='core_dingtalk_sync_log') op.drop_index(op.f('ix_core_dingtalk_sync_log_sys_create_datetime'), table_name='core_dingtalk_sync_log') op.drop_index(op.f('ix_core_dingtalk_sync_log_sync_type'), table_name='core_dingtalk_sync_log') op.drop_index(op.f('ix_core_dingtalk_sync_log_status'), table_name='core_dingtalk_sync_log') op.drop_index(op.f('ix_core_dingtalk_sync_log_is_deleted'), table_name='core_dingtalk_sync_log') op.drop_table('core_dingtalk_sync_log') op.drop_index(op.f('ix_core_dict_item_value'), table_name='core_dict_item') op.drop_index(op.f('ix_core_dict_item_sys_update_datetime'), table_name='core_dict_item') op.drop_index(op.f('ix_core_dict_item_sys_dept_id'), table_name='core_dict_item') op.drop_index(op.f('ix_core_dict_item_sys_creator_id'), table_name='core_dict_item') op.drop_index(op.f('ix_core_dict_item_sys_create_datetime'), table_name='core_dict_item') op.drop_index(op.f('ix_core_dict_item_status'), table_name='core_dict_item') op.drop_index(op.f('ix_core_dict_item_label'), table_name='core_dict_item') op.drop_index(op.f('ix_core_dict_item_is_deleted'), table_name='core_dict_item') op.drop_index(op.f('ix_core_dict_item_dict_id'), table_name='core_dict_item') op.drop_table('core_dict_item') op.drop_index(op.f('ix_core_dict_sys_update_datetime'), table_name='core_dict') op.drop_index(op.f('ix_core_dict_sys_dept_id'), table_name='core_dict') op.drop_index(op.f('ix_core_dict_sys_creator_id'), table_name='core_dict') op.drop_index(op.f('ix_core_dict_sys_create_datetime'), table_name='core_dict') op.drop_index(op.f('ix_core_dict_status'), table_name='core_dict') op.drop_index(op.f('ix_core_dict_name'), table_name='core_dict') op.drop_index(op.f('ix_core_dict_is_deleted'), table_name='core_dict') op.drop_index(op.f('ix_core_dict_code'), table_name='core_dict') op.drop_index(op.f('ix_core_dict_application_id'), table_name='core_dict') op.drop_table('core_dict') op.drop_index(op.f('ix_core_dept_wecom_dept_id'), table_name='core_dept') op.drop_index(op.f('ix_core_dept_sys_update_datetime'), table_name='core_dept') op.drop_index(op.f('ix_core_dept_sys_dept_id'), table_name='core_dept') op.drop_index(op.f('ix_core_dept_sys_creator_id'), table_name='core_dept') op.drop_index(op.f('ix_core_dept_sys_create_datetime'), table_name='core_dept') op.drop_index(op.f('ix_core_dept_status'), table_name='core_dept') op.drop_index(op.f('ix_core_dept_path'), table_name='core_dept') op.drop_index(op.f('ix_core_dept_parent_id'), table_name='core_dept') op.drop_index(op.f('ix_core_dept_name'), table_name='core_dept') op.drop_index(op.f('ix_core_dept_level'), table_name='core_dept') op.drop_index(op.f('ix_core_dept_is_deleted'), table_name='core_dept') op.drop_index(op.f('ix_core_dept_feishu_dept_id'), table_name='core_dept') op.drop_index(op.f('ix_core_dept_dingtalk_dept_id'), table_name='core_dept') op.drop_index(op.f('ix_core_dept_dept_type'), table_name='core_dept') op.drop_index(op.f('ix_core_dept_code'), table_name='core_dept') op.drop_table('core_dept') op.drop_index(op.f('ix_core_data_source_sys_update_datetime'), table_name='core_data_source') op.drop_index(op.f('ix_core_data_source_sys_dept_id'), table_name='core_data_source') op.drop_index(op.f('ix_core_data_source_sys_creator_id'), table_name='core_data_source') op.drop_index(op.f('ix_core_data_source_sys_create_datetime'), table_name='core_data_source') op.drop_index(op.f('ix_core_data_source_is_deleted'), table_name='core_data_source') op.drop_index(op.f('ix_core_data_source_code'), table_name='core_data_source') op.drop_index(op.f('ix_core_data_source_application_id'), table_name='core_data_source') op.drop_table('core_data_source') op.drop_index(op.f('ix_core_conversation_member_sys_update_datetime'), table_name='core_conversation_member') op.drop_index(op.f('ix_core_conversation_member_sys_dept_id'), table_name='core_conversation_member') op.drop_index(op.f('ix_core_conversation_member_sys_creator_id'), table_name='core_conversation_member') op.drop_index(op.f('ix_core_conversation_member_sys_create_datetime'), table_name='core_conversation_member') op.drop_index(op.f('ix_core_conversation_member_is_deleted'), table_name='core_conversation_member') op.drop_index('idx_conv_member_user_id', table_name='core_conversation_member') op.drop_index('idx_conv_member_conv_user', table_name='core_conversation_member') op.drop_index('idx_conv_member_conv_id', table_name='core_conversation_member') op.drop_table('core_conversation_member') op.drop_index(op.f('ix_core_conversation_sys_update_datetime'), table_name='core_conversation') op.drop_index(op.f('ix_core_conversation_sys_dept_id'), table_name='core_conversation') op.drop_index(op.f('ix_core_conversation_sys_creator_id'), table_name='core_conversation') op.drop_index(op.f('ix_core_conversation_sys_create_datetime'), table_name='core_conversation') op.drop_index(op.f('ix_core_conversation_is_deleted'), table_name='core_conversation') op.drop_index('idx_conversation_type', table_name='core_conversation') op.drop_index('idx_conversation_last_msg_time', table_name='core_conversation') op.drop_table('core_conversation') op.drop_index(op.f('ix_core_chat_message_sys_update_datetime'), table_name='core_chat_message') op.drop_index(op.f('ix_core_chat_message_sys_dept_id'), table_name='core_chat_message') op.drop_index(op.f('ix_core_chat_message_sys_creator_id'), table_name='core_chat_message') op.drop_index(op.f('ix_core_chat_message_sys_create_datetime'), table_name='core_chat_message') op.drop_index(op.f('ix_core_chat_message_is_deleted'), table_name='core_chat_message') op.drop_index('idx_chat_msg_sender_id', table_name='core_chat_message') op.drop_index('idx_chat_msg_conv_id_created', table_name='core_chat_message') op.drop_table('core_chat_message') op.drop_index(op.f('ix_core_application_sys_update_datetime'), table_name='core_application') op.drop_index(op.f('ix_core_application_sys_dept_id'), table_name='core_application') op.drop_index(op.f('ix_core_application_sys_creator_id'), table_name='core_application') op.drop_index(op.f('ix_core_application_sys_create_datetime'), table_name='core_application') op.drop_index(op.f('ix_core_application_status'), table_name='core_application') op.drop_index(op.f('ix_core_application_owner_id'), table_name='core_application') op.drop_index(op.f('ix_core_application_is_deleted'), table_name='core_application') op.drop_index(op.f('ix_core_application_code'), table_name='core_application') op.drop_index(op.f('ix_core_application_app_type'), table_name='core_application') op.drop_table('core_application') op.drop_index(op.f('ix_core_api_token_user_id'), table_name='core_api_token') op.drop_index(op.f('ix_core_api_token_token_hash'), table_name='core_api_token') op.drop_index(op.f('ix_core_api_token_sys_update_datetime'), table_name='core_api_token') op.drop_index(op.f('ix_core_api_token_sys_dept_id'), table_name='core_api_token') op.drop_index(op.f('ix_core_api_token_sys_creator_id'), table_name='core_api_token') op.drop_index(op.f('ix_core_api_token_sys_create_datetime'), table_name='core_api_token') op.drop_index(op.f('ix_core_api_token_is_deleted'), table_name='core_api_token') op.drop_table('core_api_token') op.drop_index(op.f('ix_core_announcement_read_user_id'), table_name='core_announcement_read') op.drop_index(op.f('ix_core_announcement_read_sys_update_datetime'), table_name='core_announcement_read') op.drop_index(op.f('ix_core_announcement_read_sys_dept_id'), table_name='core_announcement_read') op.drop_index(op.f('ix_core_announcement_read_sys_creator_id'), table_name='core_announcement_read') op.drop_index(op.f('ix_core_announcement_read_sys_create_datetime'), table_name='core_announcement_read') op.drop_index(op.f('ix_core_announcement_read_is_deleted'), table_name='core_announcement_read') op.drop_index(op.f('ix_core_announcement_read_announcement_id'), table_name='core_announcement_read') op.drop_index('ix_announcement_read_unique', table_name='core_announcement_read') op.drop_table('core_announcement_read') op.drop_index(op.f('ix_core_announcement_sys_update_datetime'), table_name='core_announcement') op.drop_index(op.f('ix_core_announcement_sys_dept_id'), table_name='core_announcement') op.drop_index(op.f('ix_core_announcement_sys_creator_id'), table_name='core_announcement') op.drop_index(op.f('ix_core_announcement_sys_create_datetime'), table_name='core_announcement') op.drop_index(op.f('ix_core_announcement_status'), table_name='core_announcement') op.drop_index(op.f('ix_core_announcement_priority'), table_name='core_announcement') op.drop_index(op.f('ix_core_announcement_is_deleted'), table_name='core_announcement') op.drop_table('core_announcement') op.drop_index(op.f('ix_contract_template_sys_update_datetime'), table_name='contract_template') op.drop_index(op.f('ix_contract_template_sys_dept_id'), table_name='contract_template') op.drop_index(op.f('ix_contract_template_sys_creator_id'), table_name='contract_template') op.drop_index(op.f('ix_contract_template_sys_create_datetime'), table_name='contract_template') op.drop_index(op.f('ix_contract_template_status'), table_name='contract_template') op.drop_index(op.f('ix_contract_template_is_deleted'), table_name='contract_template') op.drop_table('contract_template') op.drop_index(op.f('ix_contract_signature_sys_update_datetime'), table_name='contract_signature') op.drop_index(op.f('ix_contract_signature_sys_dept_id'), table_name='contract_signature') op.drop_index(op.f('ix_contract_signature_sys_creator_id'), table_name='contract_signature') op.drop_index(op.f('ix_contract_signature_sys_create_datetime'), table_name='contract_signature') op.drop_index(op.f('ix_contract_signature_is_deleted'), table_name='contract_signature') op.drop_index(op.f('ix_contract_signature_contract_id'), table_name='contract_signature') op.drop_table('contract_signature') op.drop_index(op.f('ix_contract_sign_token_sys_update_datetime'), table_name='contract_sign_token') op.drop_index(op.f('ix_contract_sign_token_sys_dept_id'), table_name='contract_sign_token') op.drop_index(op.f('ix_contract_sign_token_sys_creator_id'), table_name='contract_sign_token') op.drop_index(op.f('ix_contract_sign_token_sys_create_datetime'), table_name='contract_sign_token') op.drop_index(op.f('ix_contract_sign_token_is_deleted'), table_name='contract_sign_token') op.drop_index(op.f('ix_contract_sign_token_contract_id'), table_name='contract_sign_token') op.drop_table('contract_sign_token') op.drop_index(op.f('ix_contract_log_sys_update_datetime'), table_name='contract_log') op.drop_index(op.f('ix_contract_log_sys_dept_id'), table_name='contract_log') op.drop_index(op.f('ix_contract_log_sys_creator_id'), table_name='contract_log') op.drop_index(op.f('ix_contract_log_sys_create_datetime'), table_name='contract_log') op.drop_index(op.f('ix_contract_log_is_deleted'), table_name='contract_log') op.drop_index(op.f('ix_contract_log_contract_id'), table_name='contract_log') op.drop_table('contract_log') op.drop_index(op.f('ix_contract_instance_template_id'), table_name='contract_instance') op.drop_index(op.f('ix_contract_instance_sys_update_datetime'), table_name='contract_instance') op.drop_index(op.f('ix_contract_instance_sys_dept_id'), table_name='contract_instance') op.drop_index(op.f('ix_contract_instance_sys_creator_id'), table_name='contract_instance') op.drop_index(op.f('ix_contract_instance_sys_create_datetime'), table_name='contract_instance') op.drop_index(op.f('ix_contract_instance_status'), table_name='contract_instance') op.drop_index(op.f('ix_contract_instance_is_deleted'), table_name='contract_instance') op.drop_index(op.f('ix_contract_instance_creator_id'), table_name='contract_instance') op.drop_table('contract_instance') op.drop_index(op.f('ix_code_sequence_sys_update_datetime'), table_name='code_sequence') op.drop_index(op.f('ix_code_sequence_sys_dept_id'), table_name='code_sequence') op.drop_index(op.f('ix_code_sequence_sys_creator_id'), table_name='code_sequence') op.drop_index(op.f('ix_code_sequence_sys_create_datetime'), table_name='code_sequence') op.drop_index(op.f('ix_code_sequence_is_deleted'), table_name='code_sequence') op.drop_index('idx_business_prefix_date', table_name='code_sequence') op.drop_table('code_sequence') op.drop_index(op.f('ix_ai_workflow_version_workflow_id'), table_name='ai_workflow_version') op.drop_index(op.f('ix_ai_workflow_version_sys_update_datetime'), table_name='ai_workflow_version') op.drop_index(op.f('ix_ai_workflow_version_sys_dept_id'), table_name='ai_workflow_version') op.drop_index(op.f('ix_ai_workflow_version_sys_creator_id'), table_name='ai_workflow_version') op.drop_index(op.f('ix_ai_workflow_version_sys_create_datetime'), table_name='ai_workflow_version') op.drop_index(op.f('ix_ai_workflow_version_is_deleted'), table_name='ai_workflow_version') op.drop_table('ai_workflow_version') op.drop_index('ix_ai_workflow_run_workflow_status', table_name='ai_workflow_run') op.drop_index(op.f('ix_ai_workflow_run_workflow_id'), table_name='ai_workflow_run') op.drop_index('ix_ai_workflow_run_user_status', table_name='ai_workflow_run') op.drop_index(op.f('ix_ai_workflow_run_user_id'), table_name='ai_workflow_run') op.drop_index(op.f('ix_ai_workflow_run_sys_update_datetime'), table_name='ai_workflow_run') op.drop_index(op.f('ix_ai_workflow_run_sys_dept_id'), table_name='ai_workflow_run') op.drop_index(op.f('ix_ai_workflow_run_sys_creator_id'), table_name='ai_workflow_run') op.drop_index(op.f('ix_ai_workflow_run_sys_create_datetime'), table_name='ai_workflow_run') op.drop_index(op.f('ix_ai_workflow_run_is_deleted'), table_name='ai_workflow_run') op.drop_index(op.f('ix_ai_workflow_run_app_id'), table_name='ai_workflow_run') op.drop_table('ai_workflow_run') op.drop_index(op.f('ix_ai_workflow_sys_update_datetime'), table_name='ai_workflow') op.drop_index(op.f('ix_ai_workflow_sys_dept_id'), table_name='ai_workflow') op.drop_index(op.f('ix_ai_workflow_sys_creator_id'), table_name='ai_workflow') op.drop_index(op.f('ix_ai_workflow_sys_create_datetime'), table_name='ai_workflow') op.drop_index(op.f('ix_ai_workflow_is_deleted'), table_name='ai_workflow') op.drop_index(op.f('ix_ai_workflow_application_id'), table_name='ai_workflow') op.drop_table('ai_workflow') op.drop_index(op.f('ix_ai_prompt_template_sys_update_datetime'), table_name='ai_prompt_template') op.drop_index(op.f('ix_ai_prompt_template_sys_dept_id'), table_name='ai_prompt_template') op.drop_index(op.f('ix_ai_prompt_template_sys_creator_id'), table_name='ai_prompt_template') op.drop_index(op.f('ix_ai_prompt_template_sys_create_datetime'), table_name='ai_prompt_template') op.drop_index(op.f('ix_ai_prompt_template_is_deleted'), table_name='ai_prompt_template') op.drop_table('ai_prompt_template') op.drop_index(op.f('ix_ai_message_sys_update_datetime'), table_name='ai_message') op.drop_index(op.f('ix_ai_message_sys_dept_id'), table_name='ai_message') op.drop_index(op.f('ix_ai_message_sys_creator_id'), table_name='ai_message') op.drop_index(op.f('ix_ai_message_sys_create_datetime'), table_name='ai_message') op.drop_index(op.f('ix_ai_message_is_deleted'), table_name='ai_message') op.drop_index(op.f('ix_ai_message_conversation_id'), table_name='ai_message') op.drop_index('ix_ai_message_conversation_created', table_name='ai_message') op.drop_table('ai_message') op.drop_index(op.f('ix_ai_llm_provider_sys_update_datetime'), table_name='ai_llm_provider') op.drop_index(op.f('ix_ai_llm_provider_sys_dept_id'), table_name='ai_llm_provider') op.drop_index(op.f('ix_ai_llm_provider_sys_creator_id'), table_name='ai_llm_provider') op.drop_index(op.f('ix_ai_llm_provider_sys_create_datetime'), table_name='ai_llm_provider') op.drop_index(op.f('ix_ai_llm_provider_is_deleted'), table_name='ai_llm_provider') op.drop_table('ai_llm_provider') op.drop_index(op.f('ix_ai_llm_model_sys_update_datetime'), table_name='ai_llm_model') op.drop_index(op.f('ix_ai_llm_model_sys_dept_id'), table_name='ai_llm_model') op.drop_index(op.f('ix_ai_llm_model_sys_creator_id'), table_name='ai_llm_model') op.drop_index(op.f('ix_ai_llm_model_sys_create_datetime'), table_name='ai_llm_model') op.drop_index(op.f('ix_ai_llm_model_provider_id'), table_name='ai_llm_model') op.drop_index(op.f('ix_ai_llm_model_is_deleted'), table_name='ai_llm_model') op.drop_table('ai_llm_model') op.drop_index(op.f('ix_ai_knowledge_segment_sys_update_datetime'), table_name='ai_knowledge_segment') op.drop_index(op.f('ix_ai_knowledge_segment_sys_dept_id'), table_name='ai_knowledge_segment') op.drop_index(op.f('ix_ai_knowledge_segment_sys_creator_id'), table_name='ai_knowledge_segment') op.drop_index(op.f('ix_ai_knowledge_segment_sys_create_datetime'), table_name='ai_knowledge_segment') op.drop_index(op.f('ix_ai_knowledge_segment_parent_segment_id'), table_name='ai_knowledge_segment') op.drop_index(op.f('ix_ai_knowledge_segment_knowledge_base_id'), table_name='ai_knowledge_segment') op.drop_index(op.f('ix_ai_knowledge_segment_is_deleted'), table_name='ai_knowledge_segment') op.drop_index(op.f('ix_ai_knowledge_segment_document_id'), table_name='ai_knowledge_segment') op.drop_index('idx_segment_kb_enabled', table_name='ai_knowledge_segment') op.drop_index('idx_segment_kb_doc', table_name='ai_knowledge_segment') op.drop_table('ai_knowledge_segment') op.drop_index(op.f('ix_ai_knowledge_retrieval_log_sys_update_datetime'), table_name='ai_knowledge_retrieval_log') op.drop_index(op.f('ix_ai_knowledge_retrieval_log_sys_dept_id'), table_name='ai_knowledge_retrieval_log') op.drop_index(op.f('ix_ai_knowledge_retrieval_log_sys_creator_id'), table_name='ai_knowledge_retrieval_log') op.drop_index(op.f('ix_ai_knowledge_retrieval_log_sys_create_datetime'), table_name='ai_knowledge_retrieval_log') op.drop_index(op.f('ix_ai_knowledge_retrieval_log_is_deleted'), table_name='ai_knowledge_retrieval_log') op.drop_index('idx_retrieval_log_user', table_name='ai_knowledge_retrieval_log') op.drop_index('idx_retrieval_log_query_time', table_name='ai_knowledge_retrieval_log') op.drop_table('ai_knowledge_retrieval_log') op.drop_index(op.f('ix_ai_knowledge_document_sys_update_datetime'), table_name='ai_knowledge_document') op.drop_index(op.f('ix_ai_knowledge_document_sys_dept_id'), table_name='ai_knowledge_document') op.drop_index(op.f('ix_ai_knowledge_document_sys_creator_id'), table_name='ai_knowledge_document') op.drop_index(op.f('ix_ai_knowledge_document_sys_create_datetime'), table_name='ai_knowledge_document') op.drop_index(op.f('ix_ai_knowledge_document_status'), table_name='ai_knowledge_document') op.drop_index(op.f('ix_ai_knowledge_document_knowledge_base_id'), table_name='ai_knowledge_document') op.drop_index(op.f('ix_ai_knowledge_document_is_deleted'), table_name='ai_knowledge_document') op.drop_index(op.f('ix_ai_knowledge_document_content_hash'), table_name='ai_knowledge_document') op.drop_table('ai_knowledge_document') op.drop_index(op.f('ix_ai_knowledge_base_sys_update_datetime'), table_name='ai_knowledge_base') op.drop_index(op.f('ix_ai_knowledge_base_sys_dept_id'), table_name='ai_knowledge_base') op.drop_index(op.f('ix_ai_knowledge_base_sys_creator_id'), table_name='ai_knowledge_base') op.drop_index(op.f('ix_ai_knowledge_base_sys_create_datetime'), table_name='ai_knowledge_base') op.drop_index(op.f('ix_ai_knowledge_base_is_deleted'), table_name='ai_knowledge_base') op.drop_index(op.f('ix_ai_knowledge_base_application_id'), table_name='ai_knowledge_base') op.drop_table('ai_knowledge_base') op.drop_index(op.f('ix_ai_knowledge_annotation_sys_update_datetime'), table_name='ai_knowledge_annotation') op.drop_index(op.f('ix_ai_knowledge_annotation_sys_dept_id'), table_name='ai_knowledge_annotation') op.drop_index(op.f('ix_ai_knowledge_annotation_sys_creator_id'), table_name='ai_knowledge_annotation') op.drop_index(op.f('ix_ai_knowledge_annotation_sys_create_datetime'), table_name='ai_knowledge_annotation') op.drop_index(op.f('ix_ai_knowledge_annotation_knowledge_base_id'), table_name='ai_knowledge_annotation') op.drop_index(op.f('ix_ai_knowledge_annotation_is_deleted'), table_name='ai_knowledge_annotation') op.drop_index('idx_annotation_kb_enabled', table_name='ai_knowledge_annotation') op.drop_table('ai_knowledge_annotation') op.drop_index(op.f('ix_ai_conversation_user_id'), table_name='ai_conversation') op.drop_index('ix_ai_conversation_user_app', table_name='ai_conversation') op.drop_index(op.f('ix_ai_conversation_sys_update_datetime'), table_name='ai_conversation') op.drop_index(op.f('ix_ai_conversation_sys_dept_id'), table_name='ai_conversation') op.drop_index(op.f('ix_ai_conversation_sys_creator_id'), table_name='ai_conversation') op.drop_index(op.f('ix_ai_conversation_sys_create_datetime'), table_name='ai_conversation') op.drop_index(op.f('ix_ai_conversation_is_deleted'), table_name='ai_conversation') op.drop_index(op.f('ix_ai_conversation_app_id'), table_name='ai_conversation') op.drop_table('ai_conversation') op.drop_index(op.f('ix_ai_app_sys_update_datetime'), table_name='ai_app') op.drop_index(op.f('ix_ai_app_sys_dept_id'), table_name='ai_app') op.drop_index(op.f('ix_ai_app_sys_creator_id'), table_name='ai_app') op.drop_index(op.f('ix_ai_app_sys_create_datetime'), table_name='ai_app') op.drop_index(op.f('ix_ai_app_model_id'), table_name='ai_app') op.drop_index(op.f('ix_ai_app_is_deleted'), table_name='ai_app') op.drop_table('ai_app') op.drop_index(op.f('ix_ai_agent_message_sys_update_datetime'), table_name='ai_agent_message') op.drop_index(op.f('ix_ai_agent_message_sys_dept_id'), table_name='ai_agent_message') op.drop_index(op.f('ix_ai_agent_message_sys_creator_id'), table_name='ai_agent_message') op.drop_index(op.f('ix_ai_agent_message_sys_create_datetime'), table_name='ai_agent_message') op.drop_index(op.f('ix_ai_agent_message_is_deleted'), table_name='ai_agent_message') op.drop_index('ix_ai_agent_message_conversation_role', table_name='ai_agent_message') op.drop_index(op.f('ix_ai_agent_message_conversation_id'), table_name='ai_agent_message') op.drop_table('ai_agent_message') op.drop_index(op.f('ix_ai_agent_conversation_user_id'), table_name='ai_agent_conversation') op.drop_index(op.f('ix_ai_agent_conversation_sys_update_datetime'), table_name='ai_agent_conversation') op.drop_index(op.f('ix_ai_agent_conversation_sys_dept_id'), table_name='ai_agent_conversation') op.drop_index(op.f('ix_ai_agent_conversation_sys_creator_id'), table_name='ai_agent_conversation') op.drop_index(op.f('ix_ai_agent_conversation_sys_create_datetime'), table_name='ai_agent_conversation') op.drop_index(op.f('ix_ai_agent_conversation_is_deleted'), table_name='ai_agent_conversation') op.drop_index('ix_ai_agent_conversation_agent_user', table_name='ai_agent_conversation') op.drop_index(op.f('ix_ai_agent_conversation_agent_id'), table_name='ai_agent_conversation') op.drop_table('ai_agent_conversation') op.drop_index(op.f('ix_ai_agent_workflow_id'), table_name='ai_agent') op.drop_index(op.f('ix_ai_agent_sys_update_datetime'), table_name='ai_agent') op.drop_index(op.f('ix_ai_agent_sys_dept_id'), table_name='ai_agent') op.drop_index(op.f('ix_ai_agent_sys_creator_id'), table_name='ai_agent') op.drop_index(op.f('ix_ai_agent_sys_create_datetime'), table_name='ai_agent') op.drop_index(op.f('ix_ai_agent_model_id'), table_name='ai_agent') op.drop_index(op.f('ix_ai_agent_is_deleted'), table_name='ai_agent') op.drop_index(op.f('ix_ai_agent_application_id'), table_name='ai_agent') op.drop_table('ai_agent') # ### end Alembic commands ###