m150106_122229_comments::safeDown()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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