46 lines
2.8 KiB
PHP
46 lines
2.8 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
use Phinx\Db\Adapter\MysqlAdapter;
|
||
use Phinx\Migration\AbstractMigration;
|
||
|
||
final class CreateNotice extends AbstractMigration
|
||
{
|
||
/**
|
||
* Change Method.
|
||
*
|
||
* Write your reversible migrations using this method.
|
||
*
|
||
* More information on writing migrations is available here:
|
||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
||
*
|
||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||
* with the Table class.
|
||
*/
|
||
public function change(): void
|
||
{
|
||
$exists = $this->hasTable('notice');
|
||
if (!$exists) {
|
||
$table = $this->table('notice', ['comment' => '消息']);
|
||
$table->addColumn('department_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => false, 'default' => 0, 'comment' => '部门/渠道id'])
|
||
->addColumn('player_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => false, 'default' => 0, 'comment' => '玩家id'])
|
||
->addColumn('source_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => false, 'default' => 0, 'comment' => '来源id'])
|
||
->addColumn('type', 'integer', ['limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => 1, 'comment' => '1 系统, 2派彩'])
|
||
->addColumn('title', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '标题'])
|
||
->addColumn('content', 'string', ['limit' => 500, 'null' => false, 'default' => '', 'comment' => '内容'])
|
||
->addColumn('status', 'integer', ['limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => 0, 'comment' => '狀態,0=未读, 1=已读'])
|
||
->addColumn('receiver', 'integer', ['limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => 1, 'comment' => '接受方,1=玩家, 2=总后台, 2=子站'])
|
||
->addColumn('is_private', 'integer', ['limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => 1, 'comment' => '是否私人消息,0=否, 1=是'])
|
||
->addColumn('admin_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'signed' => false, 'null' => false, 'default' => 0, 'comment' => '管理员id'])
|
||
->addColumn('admin_name', 'string', ['limit' => 20, 'null' => false, 'default' => '', 'comment' => '管理员名称'])
|
||
->addColumn('created_at', 'datetime', ['comment' => '创建时间'])
|
||
->addColumn('updated_at', 'datetime', ['comment' => '更新时间'])
|
||
->addColumn('deleted_at', 'datetime', ['comment' => '删除时间'])
|
||
->addIndex(['department_id'], ['name' => 'idx_department_id'])
|
||
->addIndex(['admin_id'], ['name' => 'idx_admin_id'])
|
||
->create();
|
||
}
|
||
}
|
||
}
|