m190731_024219_table_article   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 24
c 2
b 0
f 0
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeDown() 0 3 1
A safeUp() 0 24 1
1
<?php
2
use App\Db\Migration;
3
4
/**
5
 * Class m190731_024219_table_article
6
 */
7
class m190731_024219_table_article extends Migration
8
{
9
    private $tableName = '{{%article}}';
10
11
    public function safeUp()
12
    {
13
        $this->createTable($this->tableName, [
14
            'id' => $this->primaryKey(),
15
            'category_id' => $this->integer()->notNull()->comment('Category ID'),
16
            'creator' => $this->integer()->notNull()->comment('Creator ID'),
17
            'title' => $this->string()->notNull()->comment('Title'),
18
            'author' => $this->string()->notNull()->defaultValue('')->comment('Author'),
19
            'summary' => $this->string()->notNull()->comment('Summary'),
20
            'cover' => $this->string()->notNull()->comment('Cover'),
21
            'status' => $this->status(),
22
            'is_deleted' => $this->softDelete(),
23
            'views' => $this->integer()->unsigned()->notNull()->defaultValue(0),
24
            'version' => $this->optimisticLock(),
25
            'release_time' => $this->timestamp('Release Time'),
26
            'create_time' => $this->createTimestamp(),
27
            'update_time' => $this->updateTimestamp(),
28
        ], $this->tableOptions());
29
30
        $this->createIndex('article_idx_creator', $this->tableName, ['creator']);
31
        $this->createIndex('article_idx_status', $this->tableName, ['status']);
32
        $this->createIndex('article_idx_is_deleted', $this->tableName, ['is_deleted']);
33
        $this->createIndex('article_idx_release_time', $this->tableName, ['release_time']);
34
        $this->createIndex('article_idx_category_id', $this->tableName, 'category_id');
35
    }
36
    
37
    public function safeDown()
38
    {
39
        $this->dropTable($this->tableName);
40
    }
41
}
42