m141230_043535_create_settings::safeUp()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 9
nc 2
nop 0
1
<?php
2
3
use yii\db\Schema;
4
5
class m141230_043535_create_settings extends \yii\db\Migration
6
{
7
    public function safeUp()
8
    {
9
        $tableOptions = null;
10
        if ($this->db->driverName === 'mysql') {
11
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
12
        }
13
14
        $this->createTable('{{%settings}}', [
15
            'key'   => Schema::TYPE_STRING . ' NOT NULL',
16
            'value' => Schema::TYPE_TEXT,
17
        ], $tableOptions);
18
19
        $this->addPrimaryKey('key', '{{%settings}}', 'key');
20
    }
21
22
    public function safeDown()
23
    {
24
        $this->dropTable('{{%settings}}');
25
    }
26
}
27