-- 客户沟通习惯表（千人千面基础数据）
CREATE TABLE IF NOT EXISTS customer_habit (
  id             BIGINT AUTO_INCREMENT PRIMARY KEY,
  company_id     BIGINT       NOT NULL,
  external_user_id VARCHAR(128) NOT NULL,
  habit_key      VARCHAR(64)  NOT NULL COMMENT '习惯维度',
  habit_value    VARCHAR(512) NOT NULL COMMENT '习惯值',
  confidence     DOUBLE       DEFAULT 0.5 COMMENT '置信度',
  source         VARCHAR(32)  DEFAULT 'AI' COMMENT '来源 AI/PROFILE/EXPLICIT',
  create_time    DATETIME     DEFAULT CURRENT_TIMESTAMP,
  update_time    DATETIME     DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  UNIQUE KEY uk_habit (company_id, external_user_id, habit_key),
  KEY idx_user (external_user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='客户沟通习惯维度表';
