/*
 Navicat Premium Dump SQL

 Source Server         : localhost
 Source Server Type    : MySQL
 Source Schema         : audio

 File Encoding         : 65001

 Feature: 用户上报耳机阻抗（最新值）
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for user_headphone_impedance
-- ----------------------------
DROP TABLE IF EXISTS `user_headphone_impedance`;
CREATE TABLE `user_headphone_impedance`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `mac_addr` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `device_model` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'Luxsin-X8/Luxsin-X9',
  `impedance_ohm` int NOT NULL COMMENT '阻抗（Ω）整数',
  `headphone_brand` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '耳机品牌（原始输入）',
  `headphone_model` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '耳机型号（原始输入）',
  `headphone_brand_norm` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '耳机品牌（trim+lower，用于去重）',
  `headphone_model_norm` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '耳机型号（trim+lower，用于去重）',
  `ip_addr` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '服务端获取的设备IP（最新值）',
  `create_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uniq_mac_brand_model`(`mac_addr` ASC, `headphone_brand_norm` ASC, `headphone_model_norm` ASC) USING BTREE,
  INDEX `idx_mac`(`mac_addr` ASC) USING BTREE,
  INDEX `idx_device_model`(`device_model` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

SET FOREIGN_KEY_CHECKS = 1;

