CREATE TABLE IF NOT EXISTS ai.tb_ai_model_config (
    model_id         VARCHAR(64) PRIMARY KEY,
    model_name       VARCHAR(128) NOT NULL,
    provider         VARCHAR(64) NOT NULL,
    endpoint         VARCHAR(255),
    adcode           VARCHAR(12),
    tenant_id        VARCHAR(64),
    tenant_path      VARCHAR(255),
    dept_id          VARCHAR(64),
    dept_path        VARCHAR(255),
    created_at       TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
COMMENT ON TABLE ai.tb_ai_model_config IS 'AI模型配置表';
COMMENT ON COLUMN ai.tb_ai_model_config.model_id IS '模型ID';
COMMENT ON COLUMN ai.tb_ai_model_config.model_name IS '模型名称';
COMMENT ON COLUMN ai.tb_ai_model_config.provider IS '模型提供商';
COMMENT ON COLUMN ai.tb_ai_model_config.endpoint IS '模型服务地址';
COMMENT ON COLUMN ai.tb_ai_model_config.adcode IS '行政区划编码';
COMMENT ON COLUMN ai.tb_ai_model_config.tenant_id IS '租户ID';
COMMENT ON COLUMN ai.tb_ai_model_config.tenant_path IS '租户路径';
COMMENT ON COLUMN ai.tb_ai_model_config.dept_id IS '部门ID';
COMMENT ON COLUMN ai.tb_ai_model_config.dept_path IS '部门路径';
COMMENT ON COLUMN ai.tb_ai_model_config.created_at IS '创建时间';

CREATE TABLE IF NOT EXISTS ai.tb_ai_task_log (
    task_id          VARCHAR(64) PRIMARY KEY,
    task_type        VARCHAR(64) NOT NULL,
    task_status      VARCHAR(32) NOT NULL,
    adcode           VARCHAR(12),
    tenant_id        VARCHAR(64),
    tenant_path      VARCHAR(255),
    dept_id          VARCHAR(64),
    dept_path        VARCHAR(255),
    payload_json     TEXT,
    created_at       TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
COMMENT ON TABLE ai.tb_ai_task_log IS 'AI任务日志表';
COMMENT ON COLUMN ai.tb_ai_task_log.task_id IS '任务ID';
COMMENT ON COLUMN ai.tb_ai_task_log.task_type IS '任务类型';
COMMENT ON COLUMN ai.tb_ai_task_log.task_status IS '任务状态';
COMMENT ON COLUMN ai.tb_ai_task_log.adcode IS '行政区划编码';
COMMENT ON COLUMN ai.tb_ai_task_log.tenant_id IS '租户ID';
COMMENT ON COLUMN ai.tb_ai_task_log.tenant_path IS '租户路径';
COMMENT ON COLUMN ai.tb_ai_task_log.dept_id IS '部门ID';
COMMENT ON COLUMN ai.tb_ai_task_log.dept_path IS '部门路径';
COMMENT ON COLUMN ai.tb_ai_task_log.payload_json IS '任务载荷JSON';
COMMENT ON COLUMN ai.tb_ai_task_log.created_at IS '创建时间';
