intimate/sql/intimate_extractor.sql
eson e1040e69cd 1.重构命名, 简化代码, 加入build.sh
2.重构数据字段结构, 使数据合理性提高.
3.测试通过openrec获取数据完整性.
TODO: 测试时区问题.
2020-07-17 18:21:38 +08:00

56 lines
1.8 KiB
SQL

create database if not exists `intimate_extractor`;
use intimate_extractor;
CREATE TABLE IF NOT EXISTS `streamer` (
`uid` bigint AUTO_INCREMENT,
`platform` varchar(255) NOT NULL,
`user_id` varchar(255) NOT NULL,
`user_name` varchar(255) NOT NULL,
`live_url` text,
`channel` varchar(128) DEFAULT NULL,
`latest_log_uid` bigint,
`ext` json DEFAULT NULL,
`update_time` Timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`uid`),
UNIQUE KEY `platform_anchor_id_idx` (`platform`, `user_id`),
KEY `platform_idx` (`platform`),
KEY `user_id_idx` (`user_id`),
KEY `user_name_idx` (`user_name`),
KEY `channel_idx` (`channel`),
KEY `update_time_idx` (`update_time`)
);
CREATE TABLE IF NOT EXISTS `collect_log` (
`log_uid` bigint AUTO_INCREMENT,
`streamer_uid` bigint,
`platform` varchar(255) NOT NULL,
`user_id` varchar(255) NOT NULL,
`is_live_streaming` tinyint(1) DEFAULT 0,
`is_error` tinyint(1) DEFAULT 0,
`followers` bigint(11) DEFAULT NULL,
`views` bigint(11) DEFAULT NULL,
`giver` json DEFAULT NULL,
`gratuity` bigint(11) DEFAULT NULL,
`live_title` text DEFAULT NULL,
`live_start_time` Timestamp NULL DEFAULT NULL,
`live_end_time` Timestamp NULL DEFAULT NULL,
`update_time` Timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`tags` json DEFAULT NULL,
`ext` json DEFAULT NULL,
`error_msg` text DEFAULT NULL,
PRIMARY KEY (`log_uid`),
KEY `streamer_uid_idx` (`streamer_uid`),
KEY `platform_idx` (`platform`),
KEY `user_id_idx` (`user_id`),
KEY `is_live_streaming_idx` (`is_live_streaming`),
KEY `is_error_idx` (`is_error`),
KEY `followers_idx` (`followers`),
KEY `views_idx` (`views`),
KEY `gratuity_idx` (`gratuity`),
KEY `update_time_idx` (`update_time`)
)