Completed
Push — master ( 745775...2faf77 )
by Alexander
48:08 queued 38:58
created

m160313_153426_session_init::up()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 24
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 5.009

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 13
cts 14
cp 0.9286
rs 8.5125
c 0
b 0
f 0
cc 5
eloc 18
nc 5
nop 0
crap 5.009
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
use yii\db\Migration;
9
10
/**
11
 * Initializes Session tables.
12
 *
13
 * @author Misbahul D Munir <[email protected]>
14
 * @since 2.0.8
15
 */
16
class m160313_153426_session_init extends Migration
17
{
18
    /**
19
     * @inheritdoc
20
     */
21 1
    public function up()
22
    {
23 1
        $dataType = $this->binary();
24 1
        $tableOptions = null;
25
26
        switch ($this->db->driverName) {
27
            case 'mysql':
28
                // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
29 1
                $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
30 1
                break;
31 1
            case 'sqlsrv':
32 1
            case 'mssql':
33 1
            case 'dblib':
34 1
                $dataType = $this->text();
35 1
                break;
36
        }
37
38
        $this->createTable('{{%session}}', [
39
            'id' => $this->string()->notNull(),
40 1
            'expire' => $this->integer(),
41
            'data' => $dataType,
42 1
            'PRIMARY KEY ([[id]])',
43 1
        ], $tableOptions);
44
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49
    public function down()
50
    {
51
        $this->dropTable('{{%session}}');
52
    }
53
}
54