<?php

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

class m150919_192054_add__admin__role__to__admin__user extends Migration
{
    public function up()
    {
    	$am = Yii::$app->authManager;
    	$user = User::find()->where('username = :name',[':name' => 'admin'])->one();
    	$role = $am->getRole('admin');
    	Yii::$app->authManager->assign($role, $user->id);
    }

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

        return false;
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}
