<?php

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

class m260218_171944_insert_admin_user extends Migration
{
    public function safeUp()
    {
        $this->insert('user', [
            'full_name' => 'Administrator',
            'phone' => '8(999)999-99-99',
            'email' => 'admin@ecofood.local',
            'password_hash' => Yii::$app->security->generatePasswordHash('ecoadmin'),
            'auth_key' => Yii::$app->security->generateRandomString(),
            'role' => 'admin',
            'created_at' => date('Y-m-d H:i:s'),
            'updated_at' => date('Y-m-d H:i:s'),
        ]);
        echo "Администратор успешно создан.\n";
    }

    public function safeDown()
    {
        $this->delete('user', ['phone' => '8(999)999-99-99']);
    }
}