m190722_062914_table_session   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 18
c 1
b 0
f 0
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeDown() 0 3 1
A safeUp() 0 19 1
1
<?php
2
use App\Db\Migration;
3
4
/**
5
 * Class m190722_062914_table_session
6
 */
7
class m190722_062914_table_session extends Migration
8
{
9
    private $tableName = '{{%session}}';
10
11
    public function safeUp()
12
    {
13
        $this->createTable($this->tableName, [
14
            'id' => $this->uuid(),
15
            'user_id' => $this->integer()->notNull()->comment('User ID'),
16
            'token' => $this->char(32)->notNull()->unique()->comment('Access Token'),
17
            'refresh_token' => $this->char(64)->notNull()->unique()->comment('Refresh Token'),
18
            'ip_address' => $this->ipAddress(),
19
            'user_agent' => $this->string()->notNull()->comment('User Agent'),
20
21
            'expire_time' => $this->timestamp('Expire Time'),
22
            'refresh_token_expire_time' => $this->timestamp('Refresh Token Expire Time'),
23
            'create_time' => $this->createTimestamp(),
24
            'update_time' => $this->updateTimestamp(),
25
        ], $this->tableOptions());
26
27
        $this->addPrimaryKey('session_pk', $this->tableName, ['id']);
28
        $this->createIndex('session_idx_user_id_expire_time', $this->tableName, ['user_id', 'expire_time']);
29
        $this->createIndex('session_idx_create_time', $this->tableName, ['create_time']);
30
    }
31
32
    public function safeDown()
33
    {
34
        $this->dropTable($this->tableName);
35
    }
36
}
37