<?php

use common\models\User;
use yii\db\Migration;

/**
 * Class m200106_093107_add_user_fingerprint
 */
class m200106_093107_add_user_fingerprint extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $user = new User();
        $user->username = 'fingerprint_system';
        $user->email = 'fingerprint_system@rocho-net.hu';
        $user->setPassword('Vn?y0c?DI|Ar6Kfvmf?$');
        $user->generateAuthKey();
        $user->save();

        $role = Yii::$app->authManager->createRole('fingerprint_system');
        Yii::$app->authManager->add($role);
        Yii::$app->authManager->assign($role, $user->id);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        echo "m200106_093107_add_user_fingerprint cannot be reverted.\n";

        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m200106_093107_add_user_fingerprint cannot be reverted.\n";

        return false;
    }
    */
}
