<?php

use Phinx\Migration\AbstractMigration;

/**
 * 积分商城用户表 mall_player
 */
class MallPlayer extends AbstractMigration
{
    public function change(): void
    {
        if (!$this->hasTable('mall_player')) {
            $table = $this->table('mall_player', [
                'id'          => false,
                'comment'     => '积分商城用户表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
                ->addColumn('username', 'string', ['limit' => 50, 'default' => '', 'comment' => '用户名', 'null' => false])
                ->addColumn('password', 'string', ['limit' => 255, 'default' => '', 'comment' => '密码', 'null' => false])
                ->addColumn('score', 'integer', ['signed' => false, 'default' => 0, 'comment' => '积分', 'null' => false])
                ->addColumn('create_time', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
                ->addColumn('update_time', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '修改时间'])
                ->addIndex(['username'])
                ->create();
        }
    }
}
