REAPI/database/migrations/20009999999989_install_product_table.php

78 lines
3.0 KiB
PHP
Raw Normal View History

<?php
use think\admin\extend\PhinxExtend;
use think\migration\Migrator;
@set_time_limit(0);
@ini_set('memory_limit', -1);
class InstallProductTable extends Migrator
{
/**
* 创建数据库
*/
public function change()
{
$this->_create_product_category();
$this->_create_product_map();
}
/**
* 创建数据对象
* @class ProductCategory
* @table product_category
* @return void
*/
private function _create_product_category()
{
// 创建数据表对象
$table = $this->table('product_category', [
'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '产品分类',
]);
// 创建或更新数据表
PhinxExtend::upgrade($table, [
['pid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上级ID']],
['title', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '分类名称']],
['icon', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '图标']],
['node', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '节点代码']],
['url', 'string', ['limit' => 400, 'default' => '', 'null' => true, 'comment' => '链接节点']],
['params', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '链接参数']],
['target', 'string', ['limit' => 20, 'default' => '_self', 'null' => true, 'comment' => '打开方式']],
['sort', 'integer', ['limit' => 11, 'default' => 0, 'null' => true, 'comment' => '排序权重']],
['status', 'tinyinteger', ['limit' => 4, 'default' => 1, 'null' => true, 'comment' => '状态(0:禁用,1:启用)']],
['create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'null' => true, 'comment' => '创建时间']],
], [
'node', 'status',
], false);
}
/**
* 创建数据对象
* @class ProductMap
* @table product_map
* @return void
*/
private function _create_product_map()
{
// 创建数据表对象
$table = $this->table('product_map', [
'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '产品-映射表',
]);
// 创建或更新数据表
PhinxExtend::upgrade($table, [
['cid', 'integer', ['default' => '0', 'null' => false, 'comment' => '渠道id']],
['pid', 'integer', ['default' => '0', 'null' => false, 'comment' => '产品id']],
['json_text', 'text', ['default' => NULL, 'null' => true, 'comment' => '需要穿给上游的json']],
['extra_param', 'text', ['default' => NULL, 'null' => true, 'comment' => '其他配置参数配置可用于自身系统']],
['key', 'string', ['limit' => 255, 'default' => '', 'null' => false, 'comment' => '产品key']],
['staus', 'tinyinteger', ['limit' => 1, 'default' => 1, 'null' => false, 'comment' => '']],
['is_deleted', 'tinyinteger', ['limit' => 1, 'default' => 0, 'null' => false, 'comment' => '']],
['create_at', 'biginteger', ['default' => NULL, 'null' => true, 'comment' => '']],
], [
], false);
}
}