feat: 新增系统用户及用户登录日志表迁移文件
This commit is contained in:
44
database/migrations/20241230054930_create_sys_user.php
Normal file
44
database/migrations/20241230054930_create_sys_user.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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', 'biginteger', ['limit' => 11, 'null' => true, 'default' => null, 'comment' => '手机号码'])
|
||||
->addColumn('email', 'string', ['limit' => 128, 'null' => false, 'comment' => '邮箱地址'])
|
||||
->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' => '更新时间'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class CreateSysUserLoginLog 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_login_log', ['engine' => 'MyISAM', 'comment' => '系统用户登录日志表']);
|
||||
$table->addColumn('user_id', 'integer', ['null' => false, 'comment' => '用户ID'])
|
||||
->addColumn('ip', 'integer', ['limit' => 10, 'null' => false, 'comment' => '登录IP'])
|
||||
->addColumn('user_agent', 'string', ['limit' => 255, 'null' => false, 'comment' => '登录设备UA信息'])
|
||||
->addColumn('message', 'string', ['limit' => 128, 'null' => true, 'default' => null, 'comment' => '消息'])
|
||||
->addColumn('status', 'boolean', ['null' => false, 'default' => 1, 'comment' => '登录状态, 1为成功, -1为失败'])
|
||||
->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user