feat: add match live table foundation

This commit is contained in:
hajimi
2026-06-21 11:11:48 +08:00
parent 5a8585d027
commit ee4f2504bd
3 changed files with 77 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
CREATE TABLE `la_match_live` (
`id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
`match_id` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '比赛ID',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '直播标题',
`source_url` varchar(500) NOT NULL DEFAULT '' COMMENT '来源链接',
`play_url_m3u8` varchar(1000) NOT NULL DEFAULT '' COMMENT '标清M3U8播放地址',
`play_url_hd_m3u8` varchar(1000) NOT NULL DEFAULT '' COMMENT '高清M3U8播放地址',
`play_url_flv` varchar(1000) NOT NULL DEFAULT '' COMMENT '标清FLV播放地址',
`play_url_hd_flv` varchar(1000) NOT NULL DEFAULT '' COMMENT '高清FLV播放地址',
`fetch_status` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '抓取状态 0-待抓取 1-成功 2-失败',
`fetch_error` varchar(255) NOT NULL DEFAULT '' COMMENT '抓取错误信息',
`last_fetch_at` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '最后抓取时间',
`next_fetch_at` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '下次抓取时间',
`create_time` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
`delete_time` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_match_source_url` (`match_id`, `source_url`) USING BTREE,
KEY `idx_match_id` (`match_id`) USING BTREE,
KEY `idx_next_fetch_at` (`next_fetch_at`) USING BTREE,
KEY `idx_fetch_status` (`fetch_status`) USING BTREE,
KEY `idx_match_create_time` (`match_id`, `create_time`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='比赛直播源表';
@@ -0,0 +1,44 @@
<?php
$root = dirname(__DIR__, 2);
$sqlPath = $root . '/docs/sql/create_match_live_table.sql';
$modelPath = $root . '/server/app/common/model/match/MatchLive.php';
if (!is_file($sqlPath)) {
fwrite(STDERR, "missing sql file\n");
exit(1);
}
if (!is_file($modelPath)) {
fwrite(STDERR, "missing model file\n");
exit(1);
}
$sql = file_get_contents($sqlPath);
$model = file_get_contents($modelPath);
$requiredSql = [
'CREATE TABLE `la_match_live`',
'`match_id` int UNSIGNED NOT NULL',
'`source_url` varchar(500)',
'`play_url_m3u8` varchar(1000)',
'`play_url_hd_m3u8` varchar(1000)',
'`play_url_flv` varchar(1000)',
'`play_url_hd_flv` varchar(1000)',
'`fetch_status` tinyint',
'UNIQUE KEY `uk_match_source_url` (`match_id`, `source_url`)',
];
foreach ($requiredSql as $needle) {
if (strpos($sql, $needle) === false) {
fwrite(STDERR, "missing sql token: {$needle}\n");
exit(1);
}
}
if (strpos($model, "protected \$name = 'match_live';") === false) {
fwrite(STDERR, "model table name mismatch\n");
exit(1);
}
echo "schema static checks passed\n";
@@ -0,0 +1,10 @@
<?php
namespace app\common\model\match;
use app\common\model\BaseModel;
class MatchLive extends BaseModel
{
protected $name = 'match_live';
}