Completed
Push — php-74-ci ( 3d1af5...9001b7 )
by Alexander
24:14 queued 23:56
created

m160313_153426_session_init::up()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 23
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 5.0406

Importance

Changes 0
Metric Value
cc 5
eloc 17
nc 5
nop 0
dl 0
loc 23
ccs 15
cts 17
cp 0.8824
crap 5.0406
rs 9.3888
c 0
b 0
f 0
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 24
    public function up()
22
    {
23 24
        $dataType = $this->binary();
24 24
        $tableOptions = null;
25
26 24
        switch ($this->db->driverName) {
27 24
            case 'mysql':
28
                // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
29 8
                $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
30 8
                break;
31 16
            case 'sqlsrv':
32 16
            case 'mssql':
33 16
            case 'dblib':
34
                $dataType = $this->text();
35
                break;
36
        }
37
38 24
        $this->createTable('{{%session}}', [
39 24
            'id' => $this->string()->notNull(),
40 24
            'expire' => $this->integer(),
41 24
            'data' => $dataType,
42 24
            'PRIMARY KEY ([[id]])',
43
        ], $tableOptions);
44 24
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 24
    public function down()
50
    {
51 24
        $this->dropTable('{{%session}}');
52 24
    }
53
}
54