m191025_123812_user.php 957 Bytes
<?php

use yii\db\Migration;

/**
 * Class m191025_123812_user
 */
class m191025_123812_user extends Migration
{
    public function up()
    {
        $tableOptions = null;
        $this->createTable('{{%user}}', [
            'id' => $this->primaryKey(),
            'login' => $this->string(64)->notNull()->unique(),
            'pass' => $this->string(64)->notNull(),
            'name' => $this->string(32)->notNull()->defaultValue(''),
            'auth_key' =>  $this->string(32)->notNull(),
            'data_created' => $this->dateTime()->notNull(),
        ], $tableOptions);


        $this->insert('{{%user}}', [
            'login' => 'admin',
            'pass' =>Yii::$app->getSecurity()->generatePasswordHash('qwerty'),
            'name' => 'Admin',
            'auth_key' => md5(time()),
            'data_created' => date("Y-m-d H:i:s")
        ]);

    }


    public function down()
    {
        $this->dropTable('{{%user}}');
    }
}