69 lines
5.2 KiB
PHP
69 lines
5.2 KiB
PHP
<?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', ['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();
|
||
}
|
||
}
|