mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-08 19:12:48 +08:00
feat: 增加系统节点数据库迁移文件
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -23,3 +23,4 @@ ul.db
|
|||||||
result.txt
|
result.txt
|
||||||
test.php
|
test.php
|
||||||
/.env.prod
|
/.env.prod
|
||||||
|
extend/base/common/command/curd/migrate_output.php
|
||||||
|
|||||||
48
database/migrations/20250823224531_system_host.php
Normal file
48
database/migrations/20250823224531_system_host.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use think\migration\Migrator;
|
||||||
|
use think\migration\db\Column;
|
||||||
|
|
||||||
|
class SystemHost extends Migrator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Change Method.
|
||||||
|
*
|
||||||
|
* Write your reversible migrations using this method.
|
||||||
|
*
|
||||||
|
* More information on writing migrations is available here:
|
||||||
|
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||||
|
*
|
||||||
|
* The following commands can be used in this method and Phinx will
|
||||||
|
* automatically reverse them when rolling back:
|
||||||
|
*
|
||||||
|
* createTable
|
||||||
|
* renameTable
|
||||||
|
* addColumn
|
||||||
|
* renameColumn
|
||||||
|
* addIndex
|
||||||
|
* addForeignKey
|
||||||
|
*
|
||||||
|
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||||
|
* with the Table class.
|
||||||
|
*/
|
||||||
|
public function change()
|
||||||
|
{
|
||||||
|
$table = $this->table('system_host')
|
||||||
|
->setComment('系统节点表')
|
||||||
|
->addColumn('node_id', 'string', ['limit' => '100', 'null' => '0', 'comment' => '节点ID {text}', ])
|
||||||
|
->addColumn('ip_address', 'string', ['limit' => '45', 'null' => '1', 'comment' => 'IP地址 {text}', ])
|
||||||
|
->addColumn('status', 'integer', ['limit' => '1', 'null' => '0', 'default' => '1', 'comment' => '状态 {switch} (0:离线,1:在线)', ])
|
||||||
|
->addColumn('last_heartbeat_at', 'datetime', ['null' => '1', 'comment' => '最后心跳时间 {date}', ])
|
||||||
|
->addColumn('os_info', 'string', ['limit' => '255', 'null' => '1', 'comment' => '系统信息 {text}', ])
|
||||||
|
->addColumn('php_version', 'string', ['limit' => '50', 'null' => '1', 'comment' => 'PHP版本 {text}', ])
|
||||||
|
->addColumn('cpu_load', 'string', ['limit' => '50', 'null' => '1', 'comment' => 'CPU负载 {text}', ])
|
||||||
|
->addColumn('memory_usage', 'biginteger', ['null' => '1', 'comment' => '内存占用(byte) {text}', ])
|
||||||
|
->addColumn('disk_free', 'biginteger', ['null' => '1', 'comment' => '磁盘可用空间(byte) {text}', ])
|
||||||
|
->addColumn('disk_total', 'biginteger', ['null' => '1', 'comment' => '磁盘总空间(byte) {text}', ])
|
||||||
|
->addColumn('create_time', 'int unsigned', ['null' => '1', 'comment' => '首次运行时间 {date}', ])
|
||||||
|
->addColumn('update_time', 'int unsigned', ['null' => '1', 'comment' => '更新时间 {date}', ])
|
||||||
|
->addIndex('node_id',['unique'=>true])
|
||||||
|
->create();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user