m161109_121736_create_session_table::up()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
cc 4
nc 4
nop 0
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