m191025_123812_user.php
957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
use yii\db\Migration;
/**
* Class m191025_123812_user
*/
class m191025_123812_user extends Migration
{
public function up()
{
$tableOptions = null;
$this->createTable('{{%user}}', [
'id' => $this->primaryKey(),
'login' => $this->string(64)->notNull()->unique(),
'pass' => $this->string(64)->notNull(),
'name' => $this->string(32)->notNull()->defaultValue(''),
'auth_key' => $this->string(32)->notNull(),
'data_created' => $this->dateTime()->notNull(),
], $tableOptions);
$this->insert('{{%user}}', [
'login' => 'admin',
'pass' =>Yii::$app->getSecurity()->generatePasswordHash('qwerty'),
'name' => 'Admin',
'auth_key' => md5(time()),
'data_created' => date("Y-m-d H:i:s")
]);
}
public function down()
{
$this->dropTable('{{%user}}');
}
}