93 lines
2.7 KiB
PHP
93 lines
2.7 KiB
PHP
|
<?php
|
||
|
|
||
|
use common\components\Migration\MigrationWithDefaultOptions;
|
||
|
use common\models\User;
|
||
|
|
||
|
class m150725_192740_seed_data extends MigrationWithDefaultOptions
|
||
|
{
|
||
|
public function safeUp()
|
||
|
{
|
||
|
$this->insert('{{%user}}', [
|
||
|
'id' => 1,
|
||
|
'username' => 'webmaster',
|
||
|
'email' => 'webmaster@example.com',
|
||
|
'password_hash' => Yii::$app->security->generatePasswordHash('webmaster'),
|
||
|
'auth_key' => Yii::$app->security->generateRandomString(),
|
||
|
'status' => User::STATUS_ACTIVE,
|
||
|
'created_at' => time(),
|
||
|
'updated_at' => time()
|
||
|
]);
|
||
|
$this->insert('{{%user}}', [
|
||
|
'id' => 2,
|
||
|
'username' => 'manager',
|
||
|
'email' => 'manager@example.com',
|
||
|
'password_hash' => Yii::$app->security->generatePasswordHash('manager'),
|
||
|
'auth_key' => Yii::$app->security->generateRandomString(),
|
||
|
'status' => User::STATUS_ACTIVE,
|
||
|
'created_at' => time(),
|
||
|
'updated_at' => time()
|
||
|
]);
|
||
|
|
||
|
$this->insert('{{%user_profile}}', [
|
||
|
'user_id' => 1,
|
||
|
'locale' => 'ru',
|
||
|
]);
|
||
|
$this->insert('{{%user_profile}}', [
|
||
|
'user_id' => 2,
|
||
|
'locale' => 'ru',
|
||
|
]);
|
||
|
|
||
|
$this->insert('{{%key_storage_item}}', [
|
||
|
'key' => 'backend.theme-skin',
|
||
|
'value' => 'skin-blue',
|
||
|
'comment' => 'skin-blue, skin-black, skin-purple, skin-green, skin-red, skin-yellow'
|
||
|
]);
|
||
|
|
||
|
$this->insert('{{%key_storage_item}}', [
|
||
|
'key' => 'backend.layout-fixed',
|
||
|
'value' => 0
|
||
|
]);
|
||
|
|
||
|
$this->insert('{{%key_storage_item}}', [
|
||
|
'key' => 'backend.layout-boxed',
|
||
|
'value' => 0
|
||
|
]);
|
||
|
|
||
|
$this->insert('{{%key_storage_item}}', [
|
||
|
'key' => 'backend.layout-collapsed-sidebar',
|
||
|
'value' => 0
|
||
|
]);
|
||
|
|
||
|
$this->insert('{{%key_storage_item}}', [
|
||
|
'key' => 'frontend.maintenance',
|
||
|
'value' => 'disabled',
|
||
|
'comment' => 'Set it to "true" to turn on maintenance mode'
|
||
|
]);
|
||
|
|
||
|
}
|
||
|
|
||
|
public function safeDown()
|
||
|
{
|
||
|
$this->delete('{{%key_storage_item}}', [
|
||
|
'key' => 'frontend.maintenance'
|
||
|
]);
|
||
|
|
||
|
$this->delete('{{%key_storage_item}}', [
|
||
|
'key' => [
|
||
|
'backend.theme-skin',
|
||
|
'backend.layout-fixed',
|
||
|
'backend.layout-boxed',
|
||
|
'backend.layout-collapsed-sidebar',
|
||
|
],
|
||
|
]);
|
||
|
|
||
|
$this->delete('{{%user_profile}}', [
|
||
|
'user_id' => [1, 2]
|
||
|
]);
|
||
|
|
||
|
$this->delete('{{%user}}', [
|
||
|
'id' => [1, 2]
|
||
|
]);
|
||
|
}
|
||
|
}
|