Completed
Push — master ( 2faf77...993eb5 )
by Dmitry
11:18
created

m160313_153426_session_init   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 38
ccs 20
cts 22
cp 0.9091
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B up() 0 24 5
A down() 0 4 1
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 15
    public function up()
22
    {
23 15
        $dataType = $this->binary();
24 15
        $tableOptions = null;
25
26 15
        switch ($this->db->driverName) {
27 15
            case 'mysql':
28
                // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
29 5
                $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
30 5
                break;
31 10
            case 'sqlsrv':
32 10
            case 'mssql':
33 10
            case 'dblib':
34
                $dataType = $this->text();
35
                break;
36
        }
37
38 15
        $this->createTable('{{%session}}', [
39 15
            'id' => $this->string()->notNull(),
40 15
            'expire' => $this->integer(),
41 15
            'data' => $dataType,
42 15
            'PRIMARY KEY ([[id]])',
43 15
        ], $tableOptions);
44 15
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49 15
    public function down()
50
    {
51 15
        $this->dropTable('{{%session}}');
52 15
    }
53
}
54