Completed
Push — master ( 0d3e8a...6919a8 )
by Razon
02:42
created

m190829_093604_article_comment   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 17
c 1
b 0
f 0
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeDown() 0 3 1
A safeUp() 0 17 1
1
<?php
2
use App\Db\Migration;
3
4
/**
5
 * Class m190829_093604_article_comment
6
 */
7
class m190829_093604_article_comment extends Migration
8
{
9
    private $tableName = '{{%article_comment}}';
10
11
    public function safeUp()
12
    {
13
        $this->createTable($this->tableName, [
14
            'id' => $this->bigPrimaryKey(),
15
            'reply_to' => $this->bigInteger()->notNull()->defaultValue(0)->comment('Reply To'),
16
            'article_id' => $this->integer()->notNull()->comment('Article ID'),
17
            'user_id' => $this->integer()->notNull()->comment('User ID'),
18
            'content' => $this->text()->notNull()->comment('Content'),
19
            'is_deleted' => $this->softDelete(),
20
            'create_time' => $this->createTimestamp(),
21
            'update_time' => $this->updateTimestamp(),
22
        ], $this->tableOptions());
23
24
        $this->createIndex('article_comment_idx_reply_to', $this->tableName, 'reply_to');
25
        $this->createIndex('article_comment_idx_article_id', $this->tableName, 'article_id');
26
        $this->createIndex('article_comment_idx_user_id', $this->tableName, 'user_id');
27
        $this->createIndex('article_comment_idx_create_time', $this->tableName, 'create_time');
28
    }
29
30
    public function safeDown()
31
    {
32
        $this->dropTable($this->tableName);
33
    }
34
}
35