m150106_122229_comments::safeUp()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 23
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 23
ccs 0
cts 20
cp 0
rs 9.0856
cc 2
eloc 17
nc 2
nop 0
crap 6
1
<?php
2
3
class m150106_122229_comments extends \yii\db\Migration
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
6
    public function safeUp()
7
    {
8
        $tableOptions = null;
9
        if ($this->db->driverName === 'mysql') {
10
            // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
11
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
12
        }
13
14
        $this->createTable('{{%comment}}', [
15
            'id' => $this->primaryKey(),
16
            'entity' => $this->string(),
17
            'text' => $this->text(),
18
            'deleted' => $this->boolean()->notNull()->defaultValue(false),
19
            'created_by' => $this->integer(),
20
            'updated_by' => $this->integer(),
21
            'created_at' => $this->integer(),
22
            'updated_at' => $this->integer(),
23
        ], $tableOptions);
24
25
        $this->createIndex('idx_entity', '{{%comment}}', ['entity']);
26
        $this->createIndex('idx_created_by', '{{%comment}}', ['created_by']);
27
        $this->createIndex('idx_created_at', '{{%comment}}', ['created_at']);
28
    }
29
30
    public function safeDown()
31
    {
32
        $this->dropTable('{{%comment}}');
33
    }
34
}
35