45 lines
944 B
PHP
45 lines
944 B
PHP
<?php
|
|
|
|
use yii\db\Schema;
|
|
use yii\db\Migration;
|
|
use common\models\User;
|
|
|
|
class m180829_155430_add_rest_user extends Migration
|
|
{
|
|
/**
|
|
* @return bool|void
|
|
* @throws Exception
|
|
*/
|
|
public function up()
|
|
{
|
|
$user = new User();
|
|
$user->username = "discount_system";
|
|
$user->email = "discount_system@rocho-net.hu";
|
|
$user->setPassword("NmqFb\ivjtX1=yT*Aw5Y");
|
|
$user->generateAuthKey();
|
|
$user->save();
|
|
|
|
$role = Yii::$app->authManager->createRole('discount_system');
|
|
Yii::$app->authManager->add($role);
|
|
Yii::$app->authManager->assign($role, $user->id);
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
echo "m180829_155430_add_rest_user cannot be reverted.\n";
|
|
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
// Use safeUp/safeDown to run migration code within a transaction
|
|
public function safeUp()
|
|
{
|
|
}
|
|
|
|
public function safeDown()
|
|
{
|
|
}
|
|
*/
|
|
}
|