m190617_031446_table_user::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
use App\Db\Migration;
3
4
/**
5
 * Class m190617_031446_table_user
6
 */
7
class m190617_031446_table_user extends Migration
8
{
9
    private $tableName = '{{%user}}';
10
11
    public function up()
12
    {
13
        $this->createTable($this->tableName, [
14
            'id' => $this->primaryKey(),
15
            'username' => $this->string()->notNull()->unique(),
16
            'first_name' => $this->string()->notNull()->defaultValue('')->comment('First Name'),
17
            'last_name' => $this->string()->notNull()->defaultValue('')->comment('Last Name'),
18
            'avatar' => $this->string()->notNull()->defaultValue('')->comment('Avatar'),
19
            'auth_key' => $this->string(32)->notNull(),
20
            'password_hash' => $this->string()->notNull(),
21
            'password_reset_token' => $this->string()->unique(),
22
            'email' => $this->string()->notNull()->unique(),
23
            'verification_token' => $this->string()->defaultValue(null),
24
            'language' => $this->string(5)->notNull()->defaultValue('en'),
25
26
            'status' => $this->status(),
27
            'is_deleted' => $this->softDelete(),
28
            'create_time' => $this->createTimestamp(),
29
            'update_time' => $this->updateTimestamp(),
30
        ], $this->tableOptions());
31
32
        $this->createIndex('user_idx_status', $this->tableName, ['status']);
33
        $this->createIndex('user_idx_is_deleted', $this->tableName, ['is_deleted']);
34
    }
35
36
    public function down()
37
    {
38
        $this->dropTable($this->tableName);
39
    }
40
}
41