Passed
Push — master ( f4169b...5ce74f )
by Loban
02:35
created

m160426_220525_settings::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
use yii\db\Migration;
4
5
class m160426_220525_settings extends Migration
6
{
7
    /**
8
     * @var string
9
     */
10
    public $tableName = '{{%settings}}';
11
12
    public function up()
13
    {
14
        $tableOptions = null;
15
        if ($this->db->driverName === 'mysql') {
16
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
17
        }
18
19
        $this->createTable($this->tableName, [
20
            // 32 (key length) + 32 (keyPrefix length)
21
            'id' => $this->string(64)->notNull() .
22
                ($this->db->driverName === 'sqlite' ? ' PRIMARY KEY' : ''),
23
24
            // Caching a query to the db with BLOB data type
25
            // https://github.com/yiisoft/yii2/issues/9899
26
            'data' => $this->text(),
27
        ], $tableOptions);
28
29
        if ($this->db->driverName !== 'sqlite') {
30
            $this->addPrimaryKey('settings_pk', $this->tableName, 'id');
31
        }
32
    }
33
34
    public function down()
35
    {
36
        $this->dropTable($this->tableName);
37
    }
38
}
39