cangku/sql/create_pricing_calculator_history_system_mysql.sql

16 lines
1.0 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 单品利润测算 v2:SPU 计算器历史记录表(系统库 shujuku3_system,MariaDB/MySQL)
-- 按用户隔离:所有查询必须带 user_id 条件,服务端强制过滤。
CREATE TABLE IF NOT EXISTS pricing_calculator_history (
id BIGINT PRIMARY KEY AUTO_INCREMENT COMMENT '主键ID',
user_id BIGINT NOT NULL COMMENT '测算人用户ID',
user_name VARCHAR(100) NULL COMMENT '测算人显示名',
spu_code VARCHAR(160) NOT NULL COMMENT '公司SPU',
brand VARCHAR(100) NULL COMMENT '品牌名称',
note VARCHAR(500) NULL COMMENT '备注',
row_count INT NOT NULL DEFAULT 0 COMMENT '测算行数',
payload_json LONGTEXT NOT NULL COMMENT '完整测算快照 JSON(输入+费率+公式结果)',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
INDEX idx_pricing_calc_history_user_created (user_id, created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='单品利润测算历史记录';