fix: align match live schema foundation

This commit is contained in:
hajimi
2026-06-21 11:21:21 +08:00
parent ee4f2504bd
commit 2496050ee7
3 changed files with 33 additions and 3 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
CREATE TABLE `la_match_live` ( CREATE TABLE IF NOT EXISTS `la_match_live` (
`id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键', `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
`match_id` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '比赛ID', `match_id` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '比赛ID',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '直播标题', `title` varchar(255) NOT NULL DEFAULT '' COMMENT '直播标题',
@@ -13,7 +13,7 @@ CREATE TABLE `la_match_live` (
`next_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 '创建时间', `create_time` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_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 '删除时间', `delete_time` int UNSIGNED DEFAULT NULL COMMENT '删除时间',
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_match_source_url` (`match_id`, `source_url`) USING BTREE, UNIQUE KEY `uk_match_source_url` (`match_id`, `source_url`) USING BTREE,
KEY `idx_match_id` (`match_id`) USING BTREE, KEY `idx_match_id` (`match_id`) USING BTREE,
+27 -1
View File
@@ -18,15 +18,26 @@ $sql = file_get_contents($sqlPath);
$model = file_get_contents($modelPath); $model = file_get_contents($modelPath);
$requiredSql = [ $requiredSql = [
'CREATE TABLE `la_match_live`', 'CREATE TABLE IF NOT EXISTS `la_match_live`',
'`match_id` int UNSIGNED NOT NULL', '`match_id` int UNSIGNED NOT NULL',
'`title` varchar(255)',
'`source_url` varchar(500)', '`source_url` varchar(500)',
'`play_url_m3u8` varchar(1000)', '`play_url_m3u8` varchar(1000)',
'`play_url_hd_m3u8` varchar(1000)', '`play_url_hd_m3u8` varchar(1000)',
'`play_url_flv` varchar(1000)', '`play_url_flv` varchar(1000)',
'`play_url_hd_flv` varchar(1000)', '`play_url_hd_flv` varchar(1000)',
'`fetch_status` tinyint', '`fetch_status` tinyint',
'`fetch_error` varchar(255)',
'`last_fetch_at` int UNSIGNED NOT NULL',
'`next_fetch_at` int UNSIGNED NOT NULL',
'`create_time` int UNSIGNED NOT NULL',
'`update_time` int UNSIGNED NOT NULL',
'`delete_time` int UNSIGNED DEFAULT NULL',
'UNIQUE KEY `uk_match_source_url` (`match_id`, `source_url`)', 'UNIQUE KEY `uk_match_source_url` (`match_id`, `source_url`)',
'KEY `idx_match_id` (`match_id`)',
'KEY `idx_next_fetch_at` (`next_fetch_at`)',
'KEY `idx_fetch_status` (`fetch_status`)',
'KEY `idx_match_create_time` (`match_id`, `create_time`)',
]; ];
foreach ($requiredSql as $needle) { foreach ($requiredSql as $needle) {
@@ -41,4 +52,19 @@ if (strpos($model, "protected \$name = 'match_live';") === false) {
exit(1); exit(1);
} }
if (strpos($model, 'extends BaseModel') === false) {
fwrite(STDERR, "model base class mismatch\n");
exit(1);
}
if (strpos($model, 'use SoftDelete;') === false) {
fwrite(STDERR, "model soft delete missing\n");
exit(1);
}
if (strpos($model, "protected \$deleteTime = 'delete_time';") === false) {
fwrite(STDERR, "model delete time mismatch\n");
exit(1);
}
echo "schema static checks passed\n"; echo "schema static checks passed\n";
@@ -3,8 +3,12 @@
namespace app\common\model\match; namespace app\common\model\match;
use app\common\model\BaseModel; use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
class MatchLive extends BaseModel class MatchLive extends BaseModel
{ {
use SoftDelete;
protected $name = 'match_live'; protected $name = 'match_live';
protected $deleteTime = 'delete_time';
} }