41 lines
2.1 KiB
PHP
41 lines
2.1 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
use Phinx\Db\Adapter\MysqlAdapter;
|
||
use Phinx\Migration\AbstractMigration;
|
||
|
||
final class CreateAdminDepartment 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_department');
|
||
if (!$exists) {
|
||
$table = $this->table('admin_department', ['comment' => '部门表']);
|
||
$table->addColumn('pid', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'signed' => false, 'null' => false, 'default' => 0, 'comment' => '上级部门'])
|
||
->addColumn('name', 'string', ['limit' => 100, 'null' => false, 'default' => '', 'comment' => '部门名称'])
|
||
->addColumn('leader', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '负责人'])
|
||
->addColumn('phone', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '手机号'])
|
||
->addColumn('status', 'integer', ['limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => 1, 'comment' => '状态:1=正常,0=禁用'])
|
||
->addColumn('type', 'integer', ['limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => 1, 'comment' => '1 部门 2渠道'])
|
||
->addColumn('sort', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => false, 'default' => 0, 'comment' => '排序'])
|
||
->addColumn('path', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '手机号'])
|
||
->addColumn('created_at', 'timestamp', ['comment' => '创建时间'])
|
||
->addColumn('updated_at', 'timestamp', ['comment' => '更新时间'])
|
||
->addColumn('deleted_at', 'timestamp', ['comment' => '删除时间'])
|
||
->create();
|
||
}
|
||
}
|
||
}
|