USE `data_center_new`;

DROP TABLE IF EXISTS `mqtt_config`;

CREATE TABLE `mqtt_config` (
   `id` bigint NOT NULL AUTO_INCREMENT,
   `company_id` bigint DEFAULT NULL,
   `mqtt_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '名称',
   `mqtt_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '格式为ip:port',
   `mqtt_username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'mqtt用户名',
   `mqtt_password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'mqtt密码',
   `mqtt_client_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
   `mqtt_topic` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
   `is_enabled` int DEFAULT '0' COMMENT '0-启动，1-关闭',
   `flag` int DEFAULT '0' COMMENT '0-正常，1-删除',
   `apikey` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
   `create_time` bigint DEFAULT NULL,
   `creator_id` bigint DEFAULT NULL,
   `modify_time` bigint DEFAULT NULL,
   `modifier_id` bigint DEFAULT NULL,
   PRIMARY KEY (`id`) USING BTREE
 ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
 
 
 
DROP TABLE IF EXISTS `mqtt_device_relation`;

CREATE TABLE `mqtt_device_relation` (
  `device_id` bigint NOT NULL COMMENT '设备信息ID',
  `mqtt_id` bigint DEFAULT NULL COMMENT 'MQTT的ID'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;