41 lines
2.2 KiB
PHP
41 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Phinx\Db\Adapter\MysqlAdapter;
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
final class CreateAdminMenus extends AbstractMigration
|
|
{
|
|
/**
|
|
* Change Method.
|
|
*
|
|
* Write your reversible migrations using this method.
|
|
*
|
|
* More information on writing migrations is available here:
|
|
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
|
*
|
|
* Remember to call "create()" or "update()" and NOT "save()" when working
|
|
* with the Table class.
|
|
*/
|
|
public function change(): void
|
|
{
|
|
$exists = $this->hasTable('admin_menus');
|
|
if (!$exists) {
|
|
$table = $this->table('admin_menus', ['comment' => '系统菜单表']);
|
|
$table->addColumn('name', 'string', ['limit' => 100, 'null' => false, 'default' => '', 'comment' => '名称'])
|
|
->addColumn('icon', 'string', ['limit' => 100, 'null' => false, 'default' => '', 'comment' => '图标'])
|
|
->addColumn('url', 'string', ['limit' => 100, 'null' => false, 'default' => '', 'comment' => '链接'])
|
|
->addColumn('plugin', 'string', ['limit' => 100, 'null' => false, 'default' => '', 'comment' => '插件名称'])
|
|
->addColumn('pid', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'signed' => false, 'null' => false, 'default' => 0, 'comment' => '父级id'])
|
|
->addColumn('sort', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => false, 'default' => 0, 'comment' => '排序'])
|
|
->addColumn('type', 'integer', ['limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => 1, 'comment' => '类型 1 总站 2渠道'])
|
|
->addColumn('status', 'integer', ['limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => 1, 'comment' => '状态(0:禁用,1:启用)'])
|
|
->addColumn('open', 'integer', ['limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => 1, 'comment' => '菜单展开(0:收起,1:展开)'])
|
|
->addColumn('created_at', 'datetime', ['comment' => '创建时间'])
|
|
->addColumn('updated_at', 'datetime', ['comment' => '更新时间'])
|
|
->create();
|
|
}
|
|
}
|
|
}
|