ApiAdmin/database/migrations/20190508152801_admin_fields.php
2019-05-08 23:49:03 +08:00

73 lines
2.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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]);
}
}