-- 需求文档：https://zzvwci6syl.feishu.cn/wiki/ZrY1wpQCBi2QLukvyEVct8PynIe


-- 艺人管理表
CREATE TABLE `kylin_artist` (
    `mid` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `artist_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '艺人ID',
    `artist_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '艺人名称',
    `pinyin` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '姓名拼音',
    `artist_type` tinyint(4) NOT NULL COMMENT '艺人类型 1音乐人 2艺术家 3厂牌 4品牌方',
    `avatar_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '艺人头像',
    `introduction` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '艺人简介',
    `status` tinyint(4) DEFAULT '1' COMMENT '状态 1启用 0禁用',
    `sort` int(11) DEFAULT '0' COMMENT '排序权重，越大越靠前',
    `created_at` datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at` datetime DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`mid`),
    UNIQUE KEY `uk_artist_id` (`artist_id`),
    UNIQUE KEY `uk_artist_name` (`artist_name`),
    KEY `idx_artist_type` (`artist_type`),
    KEY `idx_status` (`status`),
    KEY `idx_created_at` (`created_at`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='艺人管理表';

-- 艺人相册表
CREATE TABLE `kylin_artist_album` (
                                      `mid` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
                                      `album_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '相册ID',
                                      `artist_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '艺人ID',
                                      `image_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '图片地址',
                                      `sort` int(11) DEFAULT '0' COMMENT '排序权重，越大越靠前',
                                      `status` tinyint(4) DEFAULT '1' COMMENT '状态 1启用 0禁用',
                                      `created_at` datetime DEFAULT NULL COMMENT '创建时间',
                                      `updated_at` datetime DEFAULT NULL COMMENT '更新时间',
                                      PRIMARY KEY (`mid`),
                                      UNIQUE KEY `uk_album_id` (`album_id`),
                                      KEY `idx_artist_id` (`artist_id`),
                                      KEY `idx_status` (`status`),
                                      KEY `idx_sort` (`sort`)
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='艺人相册表';

-- 艺人-演出关联表
CREATE TABLE `kylin_artist_performance` (
                                            `mid` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增主键ID',
                                            `artist_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '关联 kylin_artist.artist_id',
                                            `performances_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '关联演出ID kylin_performances.performances_id',
                                            `times_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '关联场次 kylin_ticket_times.ticket_times_id',
                                            `sort` int(11) DEFAULT '0' COMMENT '该艺人在本演出中的排序权重，越大越靠前',
                                            `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                            `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                            PRIMARY KEY (`mid`),
                                            UNIQUE KEY `uk_artist_performance` (`artist_id`,`performances_id`,`times_id`) USING BTREE COMMENT '艺人、演出、场次唯一索引',
                                            KEY `idx_performances_id` (`performances_id`),
                                            KEY `idx_artist_id` (`artist_id`)
) ENGINE=InnoDB AUTO_INCREMENT=83 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='艺人-演出关联表';


-- 艺人操作记录表
CREATE TABLE `kylin_artist_operation_log` (
                                              `mid` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增主键ID',
                                              `log_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '日志ID',
                                              `artist_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '关联艺人ID kylin_artist.artist_id',
                                              `operation_type` tinyint(4) NOT NULL COMMENT '操作类型 1新增 2编辑 3删除',
                                              `operation_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '修改内容描述',
                                              `operator_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '操作人ID',
                                              `operator_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '操作人名称',
                                              `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '操作时间',
                                              PRIMARY KEY (`mid`),
                                              KEY `idx_artist_id` (`artist_id`),
                                              KEY `idx_log_id` (`log_id`),
                                              KEY `idx_created_at` (`created_at`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;