Files
ulthon_admin/database/migrations/20260816203001_system_mcp_key.php

34 lines
2.0 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;
class SystemMcpKey extends Migrator
{
/**
* MCP密钥表.
*
* 明文密钥永不出现在本表:
* - key 存 SHA-256 哈希char 64唯一索引
* - key_prefix 存明文前 16 位char 16展示用
*/
public function change()
{
$table = $this->table('system_mcp_key')
->setComment('MCP密钥表')
->addColumn('title', 'char', ['limit' => 50, 'null' => true, 'comment' => '密钥名称'])
->addColumn('key', 'char', ['limit' => 64, 'null' => true, 'comment' => '密钥SHA-256哈希'])
->addColumn('key_prefix', 'char', ['limit' => 16, 'null' => true, 'default' => '', 'comment' => '密钥前缀(展示用)'])
->addColumn('bind_admin_id', 'biginteger', ['limit' => 11, 'null' => true, 'signed' => false, 'comment' => '绑定创建者ID'])
->addColumn('status', 'integer', ['limit' => 11, 'null' => true, 'default' => 1, 'comment' => '状态 {radio} (0:禁用,1:启用)'])
->addColumn('remark', 'char', ['limit' => 255, 'null' => true, 'default' => '', 'comment' => ''])
->addColumn('use_num', 'biginteger', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '调用次数'])
->addColumn('last_use_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '最后使用时间'])
->addColumn('create_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '创建时间'])
->addColumn('update_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '更新时间'])
->addColumn('delete_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '删除时间'])
->addIndex(['key'], ['unique' => true, 'name' => 'key'])
->addIndex(['delete_time'], ['name' => 'delete_time'])
->create();
}
}