m161109_121736_create_session_table   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 28
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 20 4
A down() 0 4 1
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Handles the creation of table `session`.
7
 */
8
class m161109_121736_create_session_table extends Migration
9
{
10
    public function up()
11
    {
12
        switch ($this->db->driverName) {
13
            case 'mysql':
14
            case 'mariadb':
15
                $dataType = 'LONGBLOB';
16
                break;
17
            case 'pgsql':
18
                $dataType = 'BYTEA';
19
                break;
20
            default:
21
                $dataType = 'TEXT';
22
        }
23
24
        $this->createTable('{{%session}}', [
25
            'id' => 'CHAR(40) NOT NULL PRIMARY KEY',
26
            'expire' => 'INTEGER',
27
            'data' => $dataType,
28
        ]);
29
    }
30
31
    public function down()
32
    {
33
        $this->dropTable('{{%session}}');
34
    }
35
}
36