84 lines
7.3 KiB
PHP
84 lines
7.3 KiB
PHP
<?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', 'integer', ['default' => 0,'signed' => true,'comment' => '是否隐藏'])
|
||
->addColumn('hiddenbreadcrumb', 'integer', ['default' => 0,'limit' => MysqlAdapter::INT_REGULAR,'signed' => true,'comment' => '是否隐藏面包屑菜单'])
|
||
->addColumn('affix', 'integer', ['default' => 0,'limit' => MysqlAdapter::INT_REGULAR,'comment' => '是否固定',])
|
||
->addColumn('fullpage', 'integer', ['default' => 0,'limit' => MysqlAdapter::INT_REGULAR,'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', ['null' => true,'signed' => true,'comment' => 'api接口列表',])
|
||
->addColumn('sort', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 1,'signed' => true,'comment' => '排序',])
|
||
->addColumn('status', 'integer', ['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', 'integer', ['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();
|
||
}
|
||
}
|