m180503_090313_create_app_table::up()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 13
nc 2
nop 0
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Handles the creation of table `app`.
7
 */
8
class m180503_090313_create_app_table extends Migration
9
{
10
    /**
11
     * @inheritdoc
12
     */
13
    public function up()
14
    {
15
        $tableOptions = null;
16
        if ($this->db->driverName === 'mysql') {
17
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
18
        }
19
        $this->createTable('{{%app}}', [
20
            'id' => $this->primaryKey(),
21
            'app_name' => $this->string(32)->notNull()->comment('App名称'),
22
            'app_description' => $this->string(125)->notNull()->defaultValue('')->comment('App简介'),
23
            'app_key' => $this->char(36)->notNull()->comment('App Key'),
24
            'app_secret' => $this->char(32)->notNull()->comment('App Secret'),
25
            'created_at' => $this->integer()->notNull()->comment('创建时间'),
26
            'updated_at' => $this->integer()->notNull()->comment('更新时间'),
27
            'status' => $this->boolean()->notNull()->defaultValue(1)->comment('状态'),
28
        ], $tableOptions);
29
    }
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function down()
35
    {
36
        $this->dropTable('{{%app}}');
37
    }
38
}
39