Files
dafuweng/db/migrations/20231115082108_create_notice.php
2026-03-02 13:44:38 +08:00

46 lines
2.8 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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();
}
}
}