CREATE TABLE IF NOT EXISTS biz_change_log (
    id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    tenant_id BIGINT UNSIGNED NOT NULL,
    biz_type VARCHAR(64) NOT NULL,
    biz_id BIGINT UNSIGNED NOT NULL,
    change_type VARCHAR(64) NOT NULL,
    field_code VARCHAR(64) DEFAULT NULL,
    field_name VARCHAR(128) DEFAULT NULL,
    before_value VARCHAR(2000) DEFAULT NULL,
    after_value VARCHAR(2000) DEFAULT NULL,
    related_user_id BIGINT UNSIGNED DEFAULT NULL,
    related_user_name VARCHAR(128) DEFAULT NULL,
    operator_user_id BIGINT UNSIGNED NOT NULL DEFAULT 0,
    operator_user_name VARCHAR(128) DEFAULT NULL,
    batch_id VARCHAR(64) DEFAULT NULL,
    remark VARCHAR(500) DEFAULT NULL,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    is_deleted TINYINT(1) NOT NULL DEFAULT 0,
    KEY idx_tenant_biz_time (tenant_id, biz_type, biz_id, created_at),
    KEY idx_tenant_batch_time (tenant_id, batch_id, created_at),
    KEY idx_tenant_type_time (tenant_id, change_type, created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='统一业务变更日志';
