m170917_140443_create_page_table   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 16 2
A down() 0 4 1
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Handles the creation of table `post`.
7
 */
8
class m170917_140443_create_page_table extends Migration
9
{
10
11
12
    /**
13
     * @inheritdoc
14
     */
15
    public function up()
16
    {
17
        $tableOptions = null;
18
        if ($this->db->driverName === 'mysql') {
19
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
20
        }
21
        $this->createTable('{{%page}}', [
22
            'id' => $this->primaryKey(),
23
            'title' => $this->string()->notNull()->comment('标题'),
24
            'slug' => $this->string()->notNull()->comment('别名'),
25
            'status' => $this->boolean()->defaultValue(1),
26
            'content' => $this->text()->comment('内容'),
27
            'created_at' => $this->integer()->notNull()->comment('创建时间'),
28
            'updated_at' => $this->integer()->notNull()->comment('更新时间'),
29
        ], $tableOptions);
30
    }
31
32
    /**
33
     * @inheritdoc
34
     */
35
    public function down()
36
    {
37
        $this->dropTable('{{%page}}');
38
    }
39
}
40