Files
CompanyProject/滴滴淘/diditao/database/migrations/20200516135019_admin_user.php
2024-09-27 01:32:49 +08:00

50 lines
2.1 KiB
PHP

<?php
use think\migration\Migrator;
use think\migration\db\Column;
class AdminUser 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('admin_user')->setCollation('utf8mb4_general_ci')->setComment('管理员用户表');
$table
->addColumn(Column::char('cellphone',11)->setComment('手机号码'))
->addColumn(Column::string('username',50)->setComment('用户名'))
->addColumn(Column::string('password',255)->setComment('登录密码'))
->addColumn(Column::string('full_name',50)->setComment('姓名'))
->addColumn(Column::string('wechat',50)->setComment('微信')->setNullable())
->addColumn(Column::string('qq',50)->setComment('QQ')->setNullable())
->addColumn(Column::tinyInteger('group_id')->setComment('用户组'))
->addColumn(Column::string('last_login_ip',50)->setComment('最后登录IP')->setNullable())
->addColumn(Column::unsignedInteger('last_login_time')->setComment('最后登录时间')->setNullable())
->addColumn(Column::unsignedInteger('delete_time')->setComment('删除时间')->setDefault(0))
->addColumn(Column::unsignedInteger('create_time')->setComment('创建时间')->setDefault(0))
->addColumn(Column::unsignedInteger('update_time')->setComment('更新时间')->setDefault(0))
->addIndex(['username'])
->addIndex(['cellphone'])
->create();
}
}