-- models/pipeline_capacity.json -- 建库时请用以下语句,支持emoji字符 -- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; drop table if exists pipeline_capacity; CREATE TABLE pipeline_capacity ( `id` VARCHAR(32) NOT NULL comment '主键', `pipeline_id` VARCHAR(32) NOT NULL comment '产线ID', `max_concurrent` int comment '最大并发数', `daily_limit` int comment '每日限额', `monthly_limit` int comment '每月限额', `today_usage` int comment '今日用量', `month_usage` int comment '本月用量', `status` VARCHAR(20) DEFAULT 'active' comment '状态', `org_id` VARCHAR(32) DEFAULT '0' comment '所属组织', `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP comment '更新时间' ,primary key(id) ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci engine=innodb comment '产线容量表' ; CREATE UNIQUE INDEX pipeline_capacity_uk_capacity_pipeline ON pipeline_capacity(pipeline_id); -- models/pipeline_pricing.json -- 建库时请用以下语句,支持emoji字符 -- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; drop table if exists pipeline_pricing; CREATE TABLE pipeline_pricing ( `id` VARCHAR(32) NOT NULL comment '主键', `pipeline_id` VARCHAR(32) NOT NULL comment '产线ID', `pricing_type` VARCHAR(20) NOT NULL comment '计费方式', `unit_price` double(15,4) NOT NULL DEFAULT '0' comment '单价', `currency` VARCHAR(10) DEFAULT 'CNY' comment '货币', `pricing_config` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci comment '定价配置JSON', `effective_date` date comment '生效日期', `expiry_date` date comment '失效日期', `status` VARCHAR(20) DEFAULT 'active' comment '状态', `org_id` VARCHAR(32) DEFAULT '0' comment '所属组织', `created_by` VARCHAR(32) comment '创建人', `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP comment '创建时间', `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP comment '更新时间' ,primary key(id) ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci engine=innodb comment '产线定价表' ; CREATE INDEX pipeline_pricing_idx_pricing_pipeline ON pipeline_pricing(pipeline_id); CREATE INDEX pipeline_pricing_idx_pricing_status_date ON pipeline_pricing(status,effective_date); -- models/pipeline_usage_log.json -- 建库时请用以下语句,支持emoji字符 -- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; drop table if exists pipeline_usage_log; CREATE TABLE pipeline_usage_log ( `id` VARCHAR(32) NOT NULL comment '主键', `pipeline_id` VARCHAR(32) NOT NULL comment '产线ID', `user_id` VARCHAR(32) comment '用户ID', `distributor_id` VARCHAR(32) comment '分销商ID', `call_count` int DEFAULT '1' comment '调用次数', `token_input` int DEFAULT '0' comment '输入Token数', `token_output` int DEFAULT '0' comment '输出Token数', `amount` double(15,4) DEFAULT '0' comment '金额', `status` VARCHAR(20) comment '状态', `error_message` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci comment '错误信息', `called_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP comment '调用时间' ,primary key(id) ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci engine=innodb comment '产线调用日志表' ; CREATE INDEX pipeline_usage_log_idx_usagelog_pipeline ON pipeline_usage_log(pipeline_id); CREATE INDEX pipeline_usage_log_idx_usagelog_called_at ON pipeline_usage_log(called_at); CREATE INDEX pipeline_usage_log_idx_usagelog_distributor ON pipeline_usage_log(distributor_id);