m010101_100001_init_comment   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 3 1
A up() 0 24 2
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Class m010101_100001_init_comment
7
 */
8
class m010101_100001_init_comment extends Migration
9
{
10
    /**
11
     * Create table `Comment`
12
     */
13
    public function up()
14
    {
15
        $tableOptions = null;
16
17
        if ('mysql' === $this->db->driverName) {
18
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
19
        }
20
21
        $this->createTable('{{%Comment}}', [
22
            'id' => $this->primaryKey(),
23
            'entity' => $this->char(10)->notNull(),
24
            'entityId' => $this->integer()->notNull(),
25
            'content' => $this->text()->notNull(),
26
            'parentId' => $this->integer()->null(),
27
            'level' => $this->smallInteger()->notNull()->defaultValue(1),
28
            'createdBy' => $this->integer()->notNull(),
29
            'updatedBy' => $this->integer()->notNull(),
30
            'status' => $this->smallInteger()->notNull()->defaultValue(1),
31
            'createdAt' => $this->integer()->notNull(),
32
            'updatedAt' => $this->integer()->notNull(),
33
        ], $tableOptions);
34
35
        $this->createIndex('idx-Comment-entity', '{{%Comment}}', 'entity');
36
        $this->createIndex('idx-Comment-status', '{{%Comment}}', 'status');
37
    }
38
39
    /**
40
     * Drop table `Comment`
41
     */
42
    public function down()
43
    {
44
        $this->dropTable('{{%Comment}}');
45
    }
46
}
47