mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-24 04:01:31 +08:00
116 lines
3.8 KiB
PHP
116 lines
3.8 KiB
PHP
<?php
|
|
|
|
use Phinx\Db\Adapter\MysqlAdapter;
|
|
|
|
class CreateOnlineTable extends Phinx\Migration\AbstractMigration
|
|
{
|
|
|
|
public function change()
|
|
{
|
|
$this->table('kg_online', [
|
|
'id' => false,
|
|
'primary_key' => ['id'],
|
|
'engine' => 'InnoDB',
|
|
'encoding' => 'utf8mb4',
|
|
'collation' => 'utf8mb4_general_ci',
|
|
'comment' => '',
|
|
'row_format' => 'DYNAMIC',
|
|
])
|
|
->addColumn('id', 'integer', [
|
|
'null' => false,
|
|
'limit' => MysqlAdapter::INT_REGULAR,
|
|
'signed' => false,
|
|
'identity' => 'enable',
|
|
'comment' => '主键编号',
|
|
])
|
|
->addColumn('user_id', 'integer', [
|
|
'null' => false,
|
|
'default' => '0',
|
|
'limit' => MysqlAdapter::INT_REGULAR,
|
|
'signed' => false,
|
|
'comment' => '用户编号',
|
|
'after' => 'id',
|
|
])
|
|
->addColumn('client_type', 'integer', [
|
|
'null' => false,
|
|
'default' => '1',
|
|
'limit' => MysqlAdapter::INT_REGULAR,
|
|
'signed' => false,
|
|
'comment' => '终端类型',
|
|
'after' => 'user_id',
|
|
])
|
|
->addColumn('client_ip', 'string', [
|
|
'null' => false,
|
|
'default' => '',
|
|
'limit' => 64,
|
|
'collation' => 'utf8mb4_general_ci',
|
|
'encoding' => 'utf8mb4',
|
|
'comment' => '终端IP',
|
|
'after' => 'client_type',
|
|
])
|
|
->addColumn('active_time', 'integer', [
|
|
'null' => false,
|
|
'default' => '0',
|
|
'limit' => MysqlAdapter::INT_REGULAR,
|
|
'signed' => false,
|
|
'comment' => '活跃时间',
|
|
'after' => 'client_ip',
|
|
])
|
|
->addColumn('create_time', 'integer', [
|
|
'null' => false,
|
|
'default' => '0',
|
|
'limit' => MysqlAdapter::INT_REGULAR,
|
|
'signed' => false,
|
|
'comment' => '创建时间',
|
|
'after' => 'active_time',
|
|
])
|
|
->addColumn('update_time', 'integer', [
|
|
'null' => false,
|
|
'default' => '0',
|
|
'limit' => MysqlAdapter::INT_REGULAR,
|
|
'signed' => false,
|
|
'comment' => '更新时间',
|
|
'after' => 'create_time',
|
|
])
|
|
->addIndex(['active_time'], [
|
|
'name' => 'active_time',
|
|
'unique' => false,
|
|
])
|
|
->addIndex(['user_id'], [
|
|
'name' => 'user_id',
|
|
'unique' => false,
|
|
])
|
|
->create();
|
|
$this->table('kg_task', [
|
|
'id' => false,
|
|
'primary_key' => ['id'],
|
|
'engine' => 'InnoDB',
|
|
'encoding' => 'utf8mb4',
|
|
'collation' => 'utf8mb4_general_ci',
|
|
'comment' => '',
|
|
'row_format' => 'DYNAMIC',
|
|
])
|
|
->save();
|
|
$this->table('kg_trade', [
|
|
'id' => false,
|
|
'primary_key' => ['id'],
|
|
'engine' => 'InnoDB',
|
|
'encoding' => 'utf8mb4',
|
|
'collation' => 'utf8mb4_general_ci',
|
|
'comment' => '主键编号',
|
|
'row_format' => 'DYNAMIC',
|
|
])
|
|
->changeColumn('channel_sn', 'string', [
|
|
'null' => false,
|
|
'default' => '',
|
|
'limit' => 64,
|
|
'collation' => 'utf8mb4_general_ci',
|
|
'encoding' => 'utf8mb4',
|
|
'comment' => '平台序号',
|
|
'after' => 'channel',
|
|
])
|
|
->save();
|
|
}
|
|
|
|
}
|