CREATE DATABASE IF NOT EXISTS `cmii_live_srs_op` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
use `cmii_live_srs_op`;
-- ----------------------------
-- Table structure for live_dvr_commit
-- ----------------------------
DROP TABLE IF EXISTS `live_dvr_commit`;
CREATE TABLE `live_dvr_commit`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'none',
  `hub` varchar(24) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'none',
  `stream` varchar(48) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT 'none',
  `dvr` int NOT NULL COMMENT 'none',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 60658 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = 'none' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for live_hls_record
-- ----------------------------
DROP TABLE IF EXISTS `live_hls_record`;
CREATE TABLE `live_hls_record`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'none',
  `hub` varchar(24) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'none',
  `stream` varchar(48) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'none',
  `time_begin` datetime(3) NULL DEFAULT NULL COMMENT 'none',
  `time_end` datetime(3) NULL DEFAULT NULL COMMENT 'none',
  `size` bigint NOT NULL COMMENT 'none',
  `status` tinyint NOT NULL COMMENT '0-ok; 1-trash; 2-deleted',
  `tail_ts` varchar(96) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'none',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uniq_record`(`hub` ASC, `stream` ASC, `time_begin` ASC) USING BTREE,
  INDEX `idx_stream`(`hub` ASC, `stream` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 10077 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'none' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for live_hls_sync_hq
-- ----------------------------
DROP TABLE IF EXISTS `live_hls_sync_hq`;
CREATE TABLE `live_hls_sync_hq`  (
  `id` int NOT NULL COMMENT 'none',
  `hq_ticket` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'none',
  `time_upd` datetime(3) NULL DEFAULT NULL COMMENT 'none',
  `status` tinyint NOT NULL COMMENT '0-ready; 1-need sync',
  `version` int NOT NULL COMMENT 'none',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'none' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for live_hls_sync_task
-- ----------------------------
DROP TABLE IF EXISTS `live_hls_sync_task`;
CREATE TABLE `live_hls_sync_task`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'none',
  `hub` varchar(24) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'none',
  `stream` varchar(48) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'none',
  `status` tinyint NOT NULL COMMENT '0-ready; 1-sync.',
  `time_upd` datetime(3) NULL DEFAULT NULL COMMENT 'none',
  `version` int NOT NULL DEFAULT 1 COMMENT 'none',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uniq_steam`(`hub` ASC, `stream` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 798 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'none' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for live_hub
-- ----------------------------
DROP TABLE IF EXISTS `live_hub`;
CREATE TABLE `live_hub`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'none',
  `hub` varchar(24) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'none',
  `dvr` int NOT NULL DEFAULT 0 COMMENT 'days for reserve, 0  for disable',
  `pub` tinyint NOT NULL DEFAULT 0 COMMENT '0: private; 1: pub push; 2 pub play; 3: pub all; 4: inherit',
  `active` tinyint NOT NULL COMMENT '1 yes, 0 no, 2 for inherit',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uniq_hub`(`hub` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'none' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for live_hub_token
-- ----------------------------
DROP TABLE IF EXISTS `live_hub_token`;
CREATE TABLE `live_hub_token`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'none',
  `hub` varchar(24) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'none',
  `token` char(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'none',
  `token_type` tinyint NOT NULL COMMENT '1 for push, 2 for pull',
  `expire` datetime NOT NULL DEFAULT '2099-12-31 23:59:59' COMMENT 'none',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uniq_hub_token`(`hub` ASC, `token_type` ASC, `token` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'none' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for live_record
-- ----------------------------
DROP TABLE IF EXISTS `live_record`;
CREATE TABLE `live_record`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'id',
  `hub` varchar(24) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'hub',
  `stream` varchar(48) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'stream',
  `time_begin` datetime(3) NULL DEFAULT NULL COMMENT 'time_begin',
  `time_end` datetime(3) NULL DEFAULT NULL COMMENT 'time_end',
  `size` bigint NOT NULL COMMENT 'size',
  `status` tinyint NOT NULL COMMENT '0-ok; 1-trash; 2-deleted',
  `last_begin` datetime(3) NULL DEFAULT NULL COMMENT 'the begin time of last segment',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uniq_record`(`hub` ASC, `stream` ASC, `time_begin` ASC) USING BTREE,
  INDEX `idx_stream`(`hub` ASC, `stream` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 138248 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'live_record' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for live_segment
-- ----------------------------
DROP TABLE IF EXISTS `live_segment`;
CREATE TABLE `live_segment`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
  `hub` varchar(24) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'hub',
  `stream` varchar(48) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'stream',
  `type` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'type',
  `fileid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT 'fileid',
  `filename` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'filename',
  `size` bigint NOT NULL COMMENT 'size',
  `time_begin` datetime(3) NOT NULL COMMENT 'time_begin',
  `time_end` datetime(3) NOT NULL COMMENT 'time_end',
  `status` tinyint NOT NULL COMMENT '0-ok; 1-trash; 2-deleted',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uniq_record`(`hub` ASC, `stream` ASC, `time_begin` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 12907179 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = 'live_segment' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for live_stream
-- ----------------------------
DROP TABLE IF EXISTS `live_stream`;
CREATE TABLE `live_stream`  (
  `id` char(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'none',
  `hub` varchar(24) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `stream` varchar(48) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `dvr` int NULL DEFAULT NULL COMMENT 'days for reserve, 0 for disable, null for inherit',
  `pub` tinyint NOT NULL DEFAULT 2 COMMENT '0: private; 1: pub push; 2 pub play; 3: pub all; 4: inherit',
  `active` tinyint NULL DEFAULT NULL COMMENT '2 for inherit',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uniq_stream`(`hub` ASC, `stream` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for live_stream_token
-- ----------------------------
DROP TABLE IF EXISTS `live_stream_token`;
CREATE TABLE `live_stream_token`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'none',
  `hub` varchar(24) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'none',
  `stream` varchar(48) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'none',
  `token` char(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'none',
  `token_type` tinyint NOT NULL COMMENT '1 for push, 2 for pull',
  `expire` datetime NOT NULL DEFAULT '2099-12-31 23:59:59' COMMENT 'none',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uniq_stream`(`hub` ASC, `stream` ASC, `token_type` ASC, `token` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 62800 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'none' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for live_sync_hq
-- ----------------------------
DROP TABLE IF EXISTS `live_sync_hq`;
CREATE TABLE `live_sync_hq`  (
  `id` int NOT NULL COMMENT 'id',
  `hq_ticket` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'hq_ticket',
  `time_upd` datetime(3) NULL DEFAULT NULL COMMENT 'time update',
  `status` tinyint NOT NULL COMMENT '0-ready; 1-need sync',
  `version` int NOT NULL COMMENT 'version',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'live_sync_hq' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for live_sync_task
-- ----------------------------
DROP TABLE IF EXISTS `live_sync_task`;
CREATE TABLE `live_sync_task`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'id',
  `hub` varchar(24) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'hub',
  `stream` varchar(48) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'stream',
  `status` tinyint NOT NULL COMMENT '0-ready; 1-sync.',
  `time_upd` datetime(3) NULL DEFAULT NULL COMMENT 'time update',
  `version` int NOT NULL DEFAULT 1 COMMENT 'version',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uniq_steam`(`hub` ASC, `stream` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1613 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'sync task' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for live_video_part
-- ----------------------------
DROP TABLE IF EXISTS `live_video_part`;
CREATE TABLE `live_video_part`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'none',
  `hub` varchar(24) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'none',
  `stream` varchar(48) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'none',
  `type` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'none',
  `fileid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT 'none',
  `filename` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'none',
  `size` bigint NOT NULL COMMENT 'none',
  `time_begin` datetime(3) NOT NULL COMMENT 'none',
  `time_end` datetime(3) NOT NULL COMMENT 'none',
  `status` tinyint NOT NULL COMMENT '0-ok; 1-trash; 2-deleted',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uniq_record`(`hub` ASC, `stream` ASC, `time_begin` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1937083 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = 'none' ROW_FORMAT = DYNAMIC;

SET FOREIGN_KEY_CHECKS = 1;
