| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 | <?phpuse yii\db\Migration;use yii\db\Schema;class m181104_073622_create_wechat_user extends Migration{    public $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB';    public function safeUp()    {        /**         * 微信用户基础表         */        $this->createTable('{{%wechat_user}}', [            'id' => Schema::TYPE_PK,            'openid' => $this->string(64)->notNull()->unique()->comment('小程序ID'),            'unionid' => $this->string(64)->null()->unique()->comment('开放平台ID'),            'tel' => $this->string(11)->null()->unique()->comment('手机号'),            'nickName' => Schema::TYPE_STRING . "(20) NOT NULL  COMMENT '昵称'",            'avatarUrl' => Schema::TYPE_STRING . "(300) NOT NULL  COMMENT '头像'",            'country' => Schema::TYPE_STRING . "(50) NOT NULL  COMMENT '国家'",            'province' => Schema::TYPE_STRING . "(50) NOT NULL  COMMENT '省份'",            'city' => Schema::TYPE_STRING . "(50) NOT NULL  COMMENT '城市'",            'language' => Schema::TYPE_STRING . "(50) NOT NULL  COMMENT '语言'",            'signature' => Schema::TYPE_STRING . "(100) NOT NULL  COMMENT '签名' DEFAULT ''",            'created_at' => Schema::TYPE_INTEGER . "(11) NOT NULL",            'updated_at' => Schema::TYPE_INTEGER . "(11) NOT NULL",            'status' => Schema::TYPE_SMALLINT . "(1) NOT NULL DEFAULT '1' COMMENT '状态'",            'gender' => Schema::TYPE_SMALLINT . "(1) NOT NULL DEFAULT '1' COMMENT '性别'",        ], $this->tableOptions);    }    public function safeDown()    {        echo "m181104_073622_create_wechat_user cannot be reverted.\n";        $this->dropTable('{{%wechat_user}}');        return false;    }    /*    // Use up()/down() to run migration code without a transaction.    public function up()    {    }    public function down()    {        echo "m181104_073622_create_wechat_user cannot be reverted.\n";        return false;    }    */}
 |