m150106_122229_comments   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 3
c 3
b 1
f 0
lcom 1
cbo 2
dl 0
loc 32
ccs 0
cts 24
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeUp() 0 23 2
A safeDown() 0 4 1
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