You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
627 B
28 lines
627 B
<?php |
|
|
|
use yii\db\Migration; |
|
|
|
/** |
|
* Class m180107_204310_add_user_roles |
|
*/ |
|
class m180107_204310_add_user_roles extends Migration |
|
{ |
|
public function safeUp() |
|
{ |
|
$this->batchInsert('{{%auth_items}}', ['type', 'name', 'description'], [ |
|
[1, 'user', 'User'], |
|
[1, 'admin', 'Admin'], |
|
]); |
|
|
|
$this->batchInsert('{{%auth_item_children}}', ['parent', 'child'], [ |
|
['admin', 'user'], |
|
]); |
|
|
|
$this->execute('INSERT INTO {{%auth_assignments}} (item_name, user_id) SELECT \'user\', u.id FROM {{%users}} u ORDER BY u.id'); |
|
} |
|
|
|
public function down() |
|
{ |
|
$this->delete('{{%auth_items}}', ['name' => ['user', 'admin']]); |
|
} |
|
}
|
|
|