REAPI/database/migrations/20009999999997_install_black_table.php

45 lines
1.2 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 InstallBlackTable extends Migrator
{
/**
* 创建数据库
*/
public function change()
{
$this->_create_black_card();
}
/**
* 创建数据对象
* @class BlackCard
* @table black_card
* @return void
*/
private function _create_black_card()
{
// 创建数据表对象
$table = $this->table('black_card', [
'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '卡号黑名单',
]);
// 创建或更新数据表
PhinxExtend::upgrade($table, [
['type', 'tinyinteger', ['default' => '1', 'null' => false, 'comment' => '1完全匹配2包含3不包含']],
['value', 'string', ['limit' => 2000, 'default' => NULL, 'null' => true, 'comment' => '卡号']],
['desc', 'string', ['limit' => 500, 'default' => NULL, 'null' => true, 'comment' => '备注']],
['status', 'tinyinteger', ['limit' => 1, 'default' => 1, 'null' => false, 'comment' => '1可用0不可用']],
['create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'null' => false, 'comment' => '']],
], [
], false);
}
}