<?php

use yii\db\Migration;

/**
 * Class m191111_102644_create_table_province
 */
class m191204_102644_create_table_province extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function up()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="用户"';
        $this->createTable('user', [
            'id' => $this->primaryKey(),
            'username'=>$this->string(255)->comment('用户名'),
            'auth_key'=>$this->string(32)->notNull()->comment(''),
            'password_hash'=>$this->string(255)->notNull()->comment(''),
            'password_reset_token'=>$this->string(255)->defaultValue(null)->comment(''),
            'name'=>$this->string(120)->comment('姓名'),
            'sex'=>$this->integer(1)->comment('性别'),
            'phone'=>$this->string(13)->comment('联系方式'),
            'email'=>$this->string(255)->comment('邮箱'),
            'role'=>$this->tinyInteger(1)->defaultValue(1)->comment('角色'),
            'status'=>$this->tinyInteger(1)->defaultValue(1)->comment('状态'),
            'access_token'=>$this->string(255)->comment('令牌'),
            'expire_at'=>$this->integer(11)->comment('令牌过期时间'),
            'nickname'=>$this->string(120)->comment('昵称'),
            'avatar'=>$this->string(255)->comment('头像'),
            'wx_openid'=>$this->string(32)->comment('微信openid'),
            'mini_openid'=>$this->string(32)->comment('小程序openid'),
            'unionid'=>$this->string(60)->comment('微信联合id'),
            'session_key'=>$this->string(120)->comment('小程序会话秘钥'),
            'member_code'=>$this->string(20)->comment('会员编号'),
            'exp_point'=>$this->integer(20)->comment('经验值'),
            'consume_point'=>$this->integer(20)->defaultValue(null)->comment('消费积分'),
            'created_at'=>$this->integer(11)->notNull()->comment('创建时间'),
            'updated_at'=>$this->integer(11)->notNull()->comment('更新时间'),
        ],$tableOptions);
    }

    /**
     * {@inheritdoc}
     */
    public function down()
    {
        $this->dropTable("user");
        return true;
    }
}