Files
ulthon_admin/database/migrations/20260726100006_nginx_stat_ua.php

27 lines
1.2 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
use think\migration\Migrator;
/**
* nginx 日志分析 - 按 User-Agent 聚合统计表
*
* 每个统计日 + UA 类型 + UA 名称一行,记录 PV/UV。
* ua_type: browser/spider/unknown/手机浏览器等ua_name: 具体名称Chrome 120 等)。
*/
class NginxStatUa extends Migrator
{
public function change()
{
$table = $this->table('nginx_stat_ua')
->setComment('nginx 按 User-Agent 聚合统计')
->addColumn('stat_date', 'integer', ['limit' => 11, 'null' => false, 'comment' => '统计日期(YYYYMMDD)', 'signed' => false])
->addColumn('ua_type', 'string', ['limit' => 20, 'default' => 'unknown', 'comment' => 'UA 类型(browser/spider/unknown)'])
->addColumn('ua_name', 'string', ['limit' => 255, 'null' => false, 'comment' => 'UA 名称(具体型号)'])
->addColumn('pv', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '页面浏览量'])
->addColumn('uv', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '独立访客数'])
->addIndex(['stat_date', 'ua_type', 'ua_name'], ['unique' => true, 'name' => 'uniq_date_type_name'])
->addIndex(['stat_date'], ['name' => 'idx_stat_date'])
->create();
}
}