-- 客户数据变更日志表
DROP TABLE IF EXISTS `customer_data_change_log`;

CREATE TABLE `customer_data_change_log` (
    `log_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '日志主键ID',
    `history_id` BIGINT(20) NOT NULL COMMENT '关联的历史记录ID',
    `customer_id` BIGINT(20) NOT NULL COMMENT '关联的客户数据ID',
    `field_name` VARCHAR(100) NOT NULL COMMENT '变更字段名称(英文)',
    `field_label` VARCHAR(100) DEFAULT NULL COMMENT '变更字段中文名称',
    `old_value` TEXT DEFAULT NULL COMMENT '变更前的值',
    `new_value` TEXT DEFAULT NULL COMMENT '变更后的值',
    `change_time` DATETIME NOT NULL COMMENT '变更时间',
    `version` INT(11) NOT NULL COMMENT '数据版本号',
    PRIMARY KEY (`log_id`),
    INDEX `idx_history_id` (`history_id`),
    INDEX `idx_customer_id` (`customer_id`),
    INDEX `idx_field_name` (`field_name`),
    INDEX `idx_change_time` (`change_time`),
    INDEX `idx_version` (`version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='客户数据变更日志表';
