mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-05-23 21:39:36 +08:00
modified 完成全部数据表建立脚本
This commit is contained in:
parent
31c45c9fdb
commit
cc1c19c9db
@ -8,5 +8,6 @@ namespace app\model;
|
|||||||
|
|
||||||
|
|
||||||
class AdminUser extends Base {
|
class AdminUser extends Base {
|
||||||
|
protected $autoWriteTimestamp = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
85
database/migrations/20190513081034_admin_user.php
Normal file
85
database/migrations/20190513081034_admin_user.php
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use think\migration\Migrator;
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CREATE TABLE `admin_user` (
|
||||||
|
* `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
* `username` varchar(64) NOT NULL DEFAULT '' COMMENT '用户名',
|
||||||
|
* `nickname` varchar(64) NOT NULL DEFAULT '' COMMENT '用户昵称',
|
||||||
|
* `password` char(32) NOT NULL DEFAULT '' COMMENT '用户密码',
|
||||||
|
* `create_time` int(10) NOT NULL DEFAULT '0' COMMENT '注册时间',
|
||||||
|
* `create_ip` bigint(11) NOT NULL COMMENT '注册IP',
|
||||||
|
* `update_time` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间',
|
||||||
|
* `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '账号状态 0封号 1正常',
|
||||||
|
* `openid` varchar(100) DEFAULT NULL COMMENT '三方登录唯一ID',
|
||||||
|
* PRIMARY KEY (`id`),
|
||||||
|
* KEY `create_time` (`create_time`)
|
||||||
|
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管理员认证信息';
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function change() {
|
||||||
|
$table = $this->table('admin_user', [
|
||||||
|
'comment' => '管理员认证信息'
|
||||||
|
])->setCollation('utf8mb4_general_ci');
|
||||||
|
$table->addColumn('username', 'string', [
|
||||||
|
'limit' => 64,
|
||||||
|
'default' => '',
|
||||||
|
'comment' => '用户名'
|
||||||
|
])->addColumn('nickname', 'string', [
|
||||||
|
'limit' => 64,
|
||||||
|
'default' => '',
|
||||||
|
'comment' => '用户昵称'
|
||||||
|
])->addColumn('password', 'char', [
|
||||||
|
'limit' => 32,
|
||||||
|
'default' => '',
|
||||||
|
'comment' => '用户密码'
|
||||||
|
])->addColumn('create_time', 'integer', [
|
||||||
|
'limit' => 11,
|
||||||
|
'default' => 0,
|
||||||
|
'comment' => '注册时间'
|
||||||
|
])->addColumn('create_ip', 'biginteger', [
|
||||||
|
'limit' => 11,
|
||||||
|
'default' => 0,
|
||||||
|
'comment' => '注册IP'
|
||||||
|
])->addColumn('update_time', 'integer', [
|
||||||
|
'limit' => 11,
|
||||||
|
'default' => 0,
|
||||||
|
'comment' => '更新时间'
|
||||||
|
])->addColumn('status', 'integer', [
|
||||||
|
'limit' => 1,
|
||||||
|
'default' => 0,
|
||||||
|
'comment' => '账号状态 0封号 1正常'
|
||||||
|
])->addColumn('openid', 'string', [
|
||||||
|
'limit' => 100,
|
||||||
|
'default' => '',
|
||||||
|
'comment' => '三方登录唯一ID'
|
||||||
|
])->addIndex(['create_time'])->create();
|
||||||
|
|
||||||
|
$table->changeColumn('id', 'integer', ['signed' => false]);
|
||||||
|
}
|
||||||
|
}
|
73
database/migrations/20190513082503_admin_user_action.php
Normal file
73
database/migrations/20190513082503_admin_user_action.php
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use think\migration\Migrator;
|
||||||
|
|
||||||
|
class AdminUserAction 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CREATE TABLE `admin_user_action` (
|
||||||
|
* `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
* `action_name` varchar(50) NOT NULL DEFAULT '' COMMENT '行为名称',
|
||||||
|
* `uid` int(11) NOT NULL DEFAULT '0' COMMENT '操作用户ID',
|
||||||
|
* `nickname` varchar(50) NOT NULL DEFAULT '' COMMENT '用户昵称',
|
||||||
|
* `add_time` int(11) NOT NULL DEFAULT '0' COMMENT '操作时间',
|
||||||
|
* `data` text COMMENT '用户提交的数据',
|
||||||
|
* `url` varchar(200) NOT NULL DEFAULT '' COMMENT '操作URL',
|
||||||
|
* PRIMARY KEY (`id`),
|
||||||
|
* KEY `uid` (`uid`)
|
||||||
|
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户操作日志';
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function change() {
|
||||||
|
$table = $this->table('admin_user_action', [
|
||||||
|
'comment' => '用户操作日志'
|
||||||
|
])->setCollation('utf8mb4_general_ci');
|
||||||
|
$table->addColumn('action_name', 'string', [
|
||||||
|
'limit' => 50,
|
||||||
|
'default' => '',
|
||||||
|
'comment' => '行为名称'
|
||||||
|
])->addColumn('uid', 'integer', [
|
||||||
|
'limit' => 11,
|
||||||
|
'default' => 0,
|
||||||
|
'comment' => '操作用户ID'
|
||||||
|
])->addColumn('nickname', 'string', [
|
||||||
|
'limit' => 50,
|
||||||
|
'default' => '',
|
||||||
|
'comment' => '用户昵称'
|
||||||
|
])->addColumn('add_time', 'integer', [
|
||||||
|
'limit' => 11,
|
||||||
|
'default' => 0,
|
||||||
|
'comment' => '操作时间'
|
||||||
|
])->addColumn('data', 'text', [
|
||||||
|
'null' => true,
|
||||||
|
'comment' => '用户提交的数据'
|
||||||
|
])->addColumn('url', 'string', [
|
||||||
|
'limit' => 200,
|
||||||
|
'default' => 0,
|
||||||
|
'comment' => '操作URL'
|
||||||
|
])->addIndex(['uid'])->create();
|
||||||
|
|
||||||
|
$table->changeColumn('id', 'integer', ['signed' => false]);
|
||||||
|
}
|
||||||
|
}
|
70
database/migrations/20190513085755_admin_user_data.php
Normal file
70
database/migrations/20190513085755_admin_user_data.php
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use think\migration\Migrator;
|
||||||
|
use think\migration\db\Column;
|
||||||
|
|
||||||
|
class AdminUserData 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CREATE TABLE `admin_user_data` (
|
||||||
|
* `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
* `login_times` int(11) NOT NULL DEFAULT '0' COMMENT '账号登录次数',
|
||||||
|
* `last_login_ip` bigint(11) NOT NULL DEFAULT '0' COMMENT '最后登录IP',
|
||||||
|
* `last_login_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后登录时间',
|
||||||
|
* `uid` int(11) NOT NULL DEFAULT '' COMMENT '用户ID',
|
||||||
|
* `head_img` text COMMENT '用户头像',
|
||||||
|
* PRIMARY KEY (`id`)
|
||||||
|
* KEY `uid` (`uid`)
|
||||||
|
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管理员数据表';
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function change() {
|
||||||
|
$table = $this->table('admin_user_data', [
|
||||||
|
'comment' => '管理员数据表'
|
||||||
|
])->setCollation('utf8mb4_general_ci');
|
||||||
|
$table->addColumn('login_times', 'integer', [
|
||||||
|
'limit' => 11,
|
||||||
|
'default' => 0,
|
||||||
|
'comment' => '账号登录次数'
|
||||||
|
])->addColumn('last_login_ip', 'biginteger', [
|
||||||
|
'limit' => 11,
|
||||||
|
'default' => 0,
|
||||||
|
'comment' => '最后登录IP'
|
||||||
|
])->addColumn('last_login_time', 'integer', [
|
||||||
|
'limit' => 11,
|
||||||
|
'default' => 0,
|
||||||
|
'comment' => '最后登录时间'
|
||||||
|
])->addColumn('uid', 'integer', [
|
||||||
|
'limit' => 11,
|
||||||
|
'default' => 0,
|
||||||
|
'comment' => '用户ID'
|
||||||
|
])->addColumn('head_img', 'text', [
|
||||||
|
'null' => true,
|
||||||
|
'comment' => '用户头像'
|
||||||
|
])->addIndex(['uid'])->create();
|
||||||
|
|
||||||
|
$table->changeColumn('id', 'integer', ['signed' => false]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user