47 lines
2.4 KiB
PHP
47 lines
2.4 KiB
PHP
<?php
|
||
|
||
use think\migration\Migrator;
|
||
|
||
class CreateSysUser 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('sys_user', ['engine' => 'MyISAM', 'comment' => '系统用户表']);
|
||
$table->addColumn('username', 'string', ['limit' => 64, 'null' => false, 'comment' => '用户名'])
|
||
->addColumn('password', 'string', ['limit' => 64, 'null' => false, 'comment' => '密码'])
|
||
->addColumn('salt', 'string', ['limit' => 16, 'null' => false, 'comment' => '密码盐值'])
|
||
->addColumn('role_id', 'integer', ['limit' => 11, 'null' => false, 'comment' => '角色ID'])
|
||
->addColumn('nickname', 'string', ['limit' => 64, 'null' => false, 'comment' => '昵称'])
|
||
->addColumn('avatar', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '头像'])
|
||
->addColumn('mobile', 'string', ['limit' => 11, 'null' => true, 'default' => null, 'comment' => '手机号码'])
|
||
->addColumn('email', 'string', ['limit' => 128, 'null' => true, 'default' => null, 'comment' => '邮箱地址'])
|
||
->addColumn('delete_disable', 'boolean', ['null' => false, 'default' => 0, 'comment' => '是否禁止删除:1为是,0为否'])
|
||
->addColumn('status', 'boolean', ['null' => false, 'default' => 1, 'comment' => '-1为禁用, 1为启用'])
|
||
->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间'])
|
||
->addColumn('updated_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', 'comment' => '更新时间'])
|
||
->addColumn('deleted_at', 'timestamp', ['null' => true, 'default' => null, 'comment' => '删除时间'])
|
||
->create();
|
||
}
|
||
}
|