modified 添加数据表迁移

This commit is contained in:
zhaoxiang 2019-05-08 23:49:03 +08:00
parent b1ece57b69
commit dfe8929abc
4 changed files with 142 additions and 3 deletions

View File

@ -34,11 +34,11 @@ class AdminAuthGroupAccess extends Migrator {
'default' => 0,
'signed' => false,
'comment' => ''
])->addColumn('groupId', 'string', [
])->addColumn('group_id', 'string', [
'limit' => 255,
'default' => '',
'comment' => ''
])->addIndex(['uid'])->addIndex(['groupId'])->create();
])->addIndex(['uid'])->addIndex(['group_id'])->create();
$table->changeColumn('id', 'integer', ['signed' => false]);
}

View File

@ -33,7 +33,7 @@ class AdminAuthRule extends Migrator {
'limit' => 80,
'default' => '',
'comment' => '规则唯一标识'
])->addColumn('groupId', 'integer', [
])->addColumn('group_id', 'integer', [
'limit' => 11,
'default' => 0,
'signed' => false,

View File

@ -0,0 +1,72 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
class AdminFields 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_fields', [
'comment' => '用于保存各个API的字段规则'
])->setCollation('utf8mb4_general_ci');
$table->addColumn('field_name', 'string', [
'limit' => 50,
'default' => '',
'comment' => '字段名称'
])->addColumn('hash', 'string', [
'limit' => 50,
'default' => '',
'comment' => '权限所属组的ID'
])->addColumn('data_type', 'integer', [
'limit' => 2,
'default' => 0,
'comment' => '数据类型来源于DataType类库'
])->addColumn('default', 'string', [
'limit' => 500,
'default' => '',
'comment' => '默认值'
])->addColumn('is_must', 'integer', [
'limit' => 2,
'default' => 0,
'comment' => '是否必须 0为不必须1为必须'
])->addColumn('range', 'string', [
'limit' => 500,
'default' => '',
'comment' => '范围Json字符串根据数据类型有不一样的含义'
])->addColumn('info', 'string', [
'limit' => 500,
'default' => '',
'comment' => '字段说明'
])->addColumn('type', 'integer', [
'limit' => 2,
'default' => 0,
'comment' => '字段用处0为request1为response'
])->addColumn('show_name', 'string', [
'limit' => 50,
'default' => '',
'comment' => 'wiki显示用字段'
])->addIndex(['hash'])->create();
$table->changeColumn('id', 'integer', ['signed' => false]);
}
}

View File

@ -0,0 +1,67 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
class AdminGroup 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_group', [
'comment' => '接口组管理'
])->setCollation('utf8mb4_general_ci');
$table->addColumn('name', 'string', [
'limit' => 128,
'default' => '',
'comment' => '组名称'
])->addColumn('description', 'text', [
'comment' => '组说明',
'null' => true
])->addColumn('status', 'integer', [
'limit' => 1,
'default' => 1,
'comment' => '状态为1正常为0禁用'
])->addColumn('hash', 'string', [
'limit' => 128,
'default' => '',
'comment' => '组标识'
])->addColumn('create_time', 'integer', [
'limit' => 11,
'default' => 0,
'comment' => '创建时间'
])->addColumn('update_time', 'integer', [
'limit' => 11,
'default' => 0,
'comment' => '修改时间'
])->addColumn('image', 'string', [
'limit' => 256,
'null' => true,
'comment' => '分组封面图'
])->addColumn('hot', 'integer', [
'limit' => 11,
'default' => 0,
'comment' => '分组热度'
])->create();
$table->changeColumn('id', 'integer', ['signed' => false]);
}
}