46 lines
1.4 KiB
PHP
46 lines
1.4 KiB
PHP
<?php
|
|
|
|
use common\models\User;
|
|
use yii\db\Migration;
|
|
|
|
/**
|
|
* Handles the creation of table `{{%user}}`.
|
|
*/
|
|
class m221203_160610_create_user_table extends Migration
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function safeUp()
|
|
{
|
|
$tableOptions = null;
|
|
if ($this->db->driverName === 'mysql') {
|
|
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
|
|
$tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB';
|
|
}
|
|
|
|
$this->createTable('{{%user}}', [
|
|
'id' => $this->primaryKey(),
|
|
'auth_key' => $this->string(32)->notNull(),
|
|
'password_hash' => $this->string()->notNull(),
|
|
'password_reset_token' => $this->string()->unique(),
|
|
'verification_token' => $this->string()->defaultValue(null),
|
|
'first_name' => $this->string(64),
|
|
'email' => $this->string()->notNull()->unique(),
|
|
'status' => $this->smallInteger()->notNull()->defaultValue(User::STATUS_UNVERIFIED),
|
|
'welcome_email_sent' => $this->boolean()->defaultValue(false),
|
|
'created_at' => $this->integer()->notNull(),
|
|
'updated_at' => $this->integer()->notNull(),
|
|
|
|
], $tableOptions);
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function safeDown()
|
|
{
|
|
$this->dropTable('{{%user}}');
|
|
}
|
|
}
|