This commit is contained in:
molong
2022-11-01 11:42:28 +08:00
parent f8927e3193
commit 5cee9dcfab
23 changed files with 550 additions and 235 deletions

View File

@@ -0,0 +1,68 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
use Phinx\Db\Adapter\MysqlAdapter;
class BaseData 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('dictionary', ['engine' => 'InnoDB', 'collation' => 'utf8_general_ci', 'comment' => '字典表' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
$table->addColumn('name', 'string', ['limit' => 15,'null' => false,'default' => '','signed' => true,'comment' => '项名称',])
->addColumn('values', 'string', ['limit' => 255,'null' => false,'default' => '','signed' => true,'comment' => '键值',])
->addColumn('dic_type', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '所属字典',])
->addColumn('create_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
->addColumn('update_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
->addColumn('delete_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '删除状态null 未删除 timestamp 已删除',])
->create();
$table = $this->table('dictionary_type', ['engine' => 'InnoDB', 'collation' => 'utf8_general_ci', 'comment' => '字典分类表' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
$table->addColumn('name', 'string', ['limit' => 15,'null' => false,'default' => '','signed' => true,'comment' => '字典名称',])
->addColumn('parent_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '父级ID',])
->addColumn('code', 'string', ['limit' => 255,'null' => false,'default' => '','signed' => true,'comment' => '编码',])
->addColumn('create_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
->addColumn('update_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
->addColumn('delete_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '删除状态null 未删除 timestamp 已删除',])
->create();
$table = $this->table('system_config', ['engine' => 'InnoDB', 'collation' => 'utf8_general_ci', 'comment' => '系统配置表' ,'id' => 'id' ,'primary_key' => ['id']]);
$table->addColumn('name', 'string', ['limit' => 100,'null' => false,'default' => null,'signed' => true,'comment' => '配置名称',])
->addColumn('title', 'string', ['limit' => 200,'null' => false,'default' => null,'signed' => true,'comment' => '配置标题',])
->addColumn('value', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => false,'signed' => true,'comment' => '配置值',])
->addColumn('type', 'string', ['limit' => 100,'null' => false,'default' => null,'signed' => true,'comment' => '表单类型',])
->addColumn('group_name', 'string', ['limit' => 100,'null' => false,'default' => null,'signed' => true,'comment' => '分组',])
->addColumn('remark', 'string', ['limit' => 200,'null' => false,'default' => null,'signed' => true,'comment' => '描述',])
->addColumn('status', 'boolean', ['null' => false,'default' => null,'signed' => true,'comment' => '状态',])
->addColumn('create_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => null,'signed' => true,'comment' => '创建时间',])
->addColumn('update_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => null,'signed' => true,'comment' => '更新时间',])
->create();
$table = $this->table('area',array('engine'=>'MyISAM'));
$table->addColumn('title', 'string',array('limit' => 255,'default'=>'','comment'=>'名称'))
->addColumn('code', 'string',array('limit'=>18,'comment'=>'编号'))
->addColumn('parent_id', 'integer',array('limit'=>11,'comment'=>'上级code'))
->addColumn('first', 'string',array('limit'=>255,'comment'=>'首字母'))
->addColumn('create_time', 'integer',array('limit'=>11, 'default'=>0,'comment'=>'创建时间'))
->addColumn('update_time', 'integer',array('limit'=>11, 'default'=>0,'comment'=>'更新时间'))
->create();
}
}

View File

@@ -0,0 +1,88 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
use Phinx\Db\Adapter\MysqlAdapter;
class UserData 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('users', ['engine' => 'InnoDB', 'collation' => 'utf8_general_ci', 'comment' => '用户表' ,'id' => 'uid','signed' => true ,'primary_key' => ['uid']]);
$table->addColumn('username', 'string', ['limit' => 15,'null' => false,'default' => '','signed' => true,'comment' => '用户名',])
->addColumn('nickname', 'string', ['limit' => 255,'null' => false,'default' => null,'signed' => true,'comment' => '姓名',])
->addColumn('password', 'string', ['limit' => 255,'null' => false,'default' => null,'signed' => true,'comment' => '用户密码',])
->addColumn('email', 'string', ['limit' => 100,'null' => true,'signed' => true,'comment' => '邮箱 登录',])
->addColumn('avatar', 'string', ['limit' => 255,'null' => true,'signed' => true,'comment' => '用户头像',])
->addColumn('remember_token', 'string', ['limit' => 512,'null' => true,'signed' => true,'comment' => '用户token',])
->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '创建人ID',])
->addColumn('department_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '部门ID',])
->addColumn('user_type', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '用户类型',])
->addColumn('status', 'boolean', ['null' => false,'default' => 1,'signed' => true,'comment' => '用户状态 1 正常 2 禁用',])
->addColumn('last_login_ip', 'string', ['limit' => 50,'null' => false,'default' => 0,'signed' => true,'comment' => '最后登录IP',])
->addColumn('last_login_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '最后登录时间',])
->addColumn('create_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
->addColumn('update_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
->addColumn('delete_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '删除状态0未删除 >0 已删除',])
->create();
$table = $this->table('departments', ['engine' => 'InnoDB', 'collation' => 'utf8_general_ci', 'comment' => '部门表' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
$table->addColumn('title', 'string', ['limit' => 15,'null' => false,'default' => '','signed' => true,'comment' => '部门名称',])
->addColumn('parent_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '父级ID',])
->addColumn('principal', 'string', ['limit' => 20,'null' => false,'default' => '','signed' => true,'comment' => '负责人',])
->addColumn('mobile', 'string', ['limit' => 20,'null' => false,'default' => '','signed' => true,'comment' => '联系电话',])
->addColumn('email', 'string', ['limit' => 100,'null' => false,'default' => '','signed' => true,'comment' => '联系又想',])
->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '创建人ID',])
->addColumn('status', 'boolean', ['null' => false,'default' => 1,'signed' => true,'comment' => '1 正常 2 停用',])
->addColumn('sort', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '排序字段',])
->addColumn('create_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
->addColumn('update_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
->addColumn('delete_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '删除状态null 未删除 timestamp 已删除',])
->create();
$table = $this->table('users_log', ['engine' => 'InnoDB', 'collation' => 'utf8_general_ci', 'comment' => '用户表' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
$table->addColumn('uid', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => null,'signed' => false,'comment' => '用户ID',])
->addColumn('title', 'string', ['limit' => 100,'null' => false,'default' => '','signed' => true,'comment' => '操作名称',])
->addColumn('method', 'string', ['limit' => 20,'null' => false,'default' => 'POST','signed' => true,'comment' => '操作类型',])
->addColumn('route', 'string', ['limit' => 255,'null' => false,'default' => '','signed' => true,'comment' => '操作路由',])
->addColumn('params', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => false,'signed' => true,'comment' => '操作参数',])
->addColumn('client_ip', 'string', ['limit' => 100,'null' => false,'default' => '','signed' => true,'comment' => '客户端IP',])
->addColumn('browser', 'string', ['limit' => 255,'null' => false,'default' => '','signed' => true,'comment' => '浏览器',])
->addColumn('code', 'string', ['limit' => 20,'null' => false,'default' => null,'signed' => true,'comment' => '状态码',])
->addColumn('create_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
->addColumn('update_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
->addColumn('delete_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '删除状态0未删除 >0 已删除',])
->create();
$table = $this->table('jobs', ['engine' => 'InnoDB', 'collation' => 'utf8_general_ci', 'comment' => '岗位表' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
$table->addColumn('job_name', 'string', ['limit' => 15,'null' => false,'default' => '','signed' => true,'comment' => '岗位名称',])
->addColumn('coding', 'string', ['limit' => 50,'null' => false,'default' => '','signed' => true,'comment' => '编码',])
->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '创建人ID',])
->addColumn('status', 'boolean', ['null' => false,'default' => 1,'signed' => true,'comment' => '1 正常 2 停用',])
->addColumn('sort', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '排序字段',])
->addColumn('description', 'string', ['limit' => 255,'null' => false,'default' => '','signed' => true,'comment' => '描述',])
->addColumn('create_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
->addColumn('update_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
->addColumn('delete_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '删除状态null 未删除 timestamp 已删除',])
->create();
}
}

View File

@@ -0,0 +1,83 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
use Phinx\Db\Adapter\MysqlAdapter;
class UserAuth 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('permissions', ['engine' => 'InnoDB', 'collation' => 'utf8_general_ci', 'comment' => '系统菜单表' ,'id' => 'id' ,'primary_key' => ['id']]);
$table->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => null,'signed' => true,'comment' => '创建人',])
->addColumn('parent_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => null,'signed' => true,'comment' => '上级ID',])
->addColumn('name', 'string', ['limit' => 200,'null' => false,'default' => null,'signed' => true,'comment' => '菜单标识',])
->addColumn('title', 'string', ['limit' => 255,'null' => true,'signed' => true,'comment' => '权限标题',])
->addColumn('type', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '栏目类型',])
->addColumn('icon', 'string', ['limit' => 100,'null' => true,'signed' => true,'comment' => '图标',])
->addColumn('color', 'string', ['limit' => 10,'null' => true,'signed' => true,'comment' => '标题颜色',])
->addColumn('hidden', 'boolean', ['null' => true,'signed' => true,'comment' => '是否隐藏',])
->addColumn('hiddenBreadcrumb', 'boolean', ['null' => true,'signed' => true,'comment' => 'hiddenBreadcrumb',])
->addColumn('affix', 'boolean', ['null' => true,'signed' => true,'comment' => '是否固定',])
->addColumn('fullpage', 'boolean', ['null' => true,'signed' => true,'comment' => '是否全屏',])
->addColumn('path', 'string', ['limit' => 200,'null' => false,'default' => null,'signed' => true,'comment' => '路径',])
->addColumn('redirect', 'string', ['limit' => 200,'null' => true,'signed' => true,'comment' => '重定向',])
->addColumn('component', 'string', ['limit' => 200,'null' => true,'signed' => true,'comment' => '组件',])
->addColumn('api_list', 'text', ['limit' => MysqlAdapter::TEXT_TINY,'null' => true,'signed' => true,'comment' => 'api接口列表',])
->addColumn('sort', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 1,'signed' => true,'comment' => '排序',])
->addColumn('status', 'boolean', ['null' => false,'default' => 1,'signed' => true,'comment' => '状态',])
->addColumn('create_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => null,'signed' => true,'comment' => '创建时间',])
->addColumn('update_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => null,'signed' => true,'comment' => '更新时间',])
->create();
$table = $this->table('roles', ['engine' => 'InnoDB', 'collation' => 'utf8_general_ci', 'comment' => '角色表' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
$table->addColumn('title', 'string', ['limit' => 15,'null' => false,'default' => '','signed' => true,'comment' => '角色名',])
->addColumn('identify', 'string', ['limit' => 20,'null' => false,'default' => 1,'signed' => true,'comment' => '角色的标识,用英文表示,用于后台路由权限',])
->addColumn('parent_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '父级ID',])
->addColumn('description', 'string', ['limit' => 255,'null' => false,'default' => '','signed' => true,'comment' => '角色备注',])
->addColumn('data_range', 'boolean', ['null' => false,'default' => 0,'signed' => true,'comment' => '1 全部数据 2 自定义数据 3 仅本人数据 4 部门数据 5 部门及以下数据',])
->addColumn('sort', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '排序',])
->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '创建人ID',])
->addColumn('create_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
->addColumn('update_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
->addColumn('delete_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '删除状态0未删除 >0 已删除',])
->create();
$table = $this->table('role_has_departments', ['engine' => 'InnoDB', 'collation' => 'utf8_general_ci', 'comment' => '角色部门表' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
$table->addColumn('role_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => null,'signed' => false,'comment' => '角色ID',])
->addColumn('department_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => null,'signed' => false,'comment' => '部门ID',])
->create();
$table = $this->table('role_has_permissions', ['engine' => 'InnoDB', 'collation' => 'utf8_general_ci', 'comment' => '角色权限表' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
$table->addColumn('role_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => null,'signed' => false,'comment' => '角色ID',])
->addColumn('permission_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => null,'signed' => false,'comment' => '权限ID',])
->create();
$table = $this->table('user_has_jobs', ['engine' => 'InnoDB', 'collation' => 'utf8_general_ci', 'comment' => '用户角色表' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
$table->addColumn('uid', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => null,'signed' => false,'comment' => '用户ID',])
->addColumn('job_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => null,'signed' => false,'comment' => '岗位ID',])
->create();
$table = $this->table('user_has_roles', ['engine' => 'InnoDB', 'collation' => 'utf8_general_ci', 'comment' => '用户角色表' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
$table->addColumn('uid', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => null,'signed' => false,'comment' => '用户ID',])
->addColumn('role_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => null,'signed' => false,'comment' => '角色ID',])
->create();
}
}

19
database/seeds/Area.php Normal file
View File

@@ -0,0 +1,19 @@
<?php
use think\migration\Seeder;
class Area extends Seeder
{
/**
* Run Method.
*
* Write your database seeder using this method.
*
* More information on writing seeders is available here:
* http://docs.phinx.org/en/latest/seeding.html
*/
public function run()
{
}
}

19
database/seeds/Users.php Normal file
View File

@@ -0,0 +1,19 @@
<?php
use think\migration\Seeder;
class Users extends Seeder
{
/**
* Run Method.
*
* Write your database seeder using this method.
*
* More information on writing seeders is available here:
* http://docs.phinx.org/en/latest/seeding.html
*/
public function run()
{
}
}