Files
ulthon_admin/database/migrations/20260814100003_xhprof_watch.php

28 lines
1.5 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;
/**
* XHProf 性能日志 - 函数监控规则表
*
* regex 为 PCRE 正则,导入任务按被调用(callee)函数名匹配,命中边聚合到 run_watch 表。
*/
class XhprofWatch extends Migrator
{
public function change()
{
$table = $this->table('xhprof_watch', ['id' => false, 'primary_key' => ['id']])
->setComment('XHProf 函数监控规则')
->addColumn('id', 'integer', ['limit' => 11, 'null' => false, 'signed' => false, 'identity' => true, 'comment' => '主键ID'])
->addColumn('name', 'string', ['limit' => 100, 'null' => false, 'comment' => '规则名称(人读)'])
->addColumn('regex', 'string', ['limit' => 255, 'null' => false, 'comment' => 'PCRE 正则(对被调用函数名匹配)'])
->addColumn('note', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '备注'])
->addColumn('threshold_ms', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '比对阈值(毫秒),0=不比对'])
->addColumn('status', 'tinyinteger', ['limit' => 4, 'default' => 1, 'comment' => '状态:1=启用,0=禁用'])
->addColumn('create_time', 'integer', ['limit' => 11, 'comment' => '创建时间戳', 'signed' => false])
->addColumn('update_time', 'integer', ['limit' => 11, 'comment' => '更新时间戳', 'signed' => false])
->addIndex(['regex'], ['unique' => true, 'name' => 'uniq_regex'])
->create();
}
}