m200730_065801_create_category_table::safeUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 15
rs 9.9
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Handles the creation of table `{{%category}}`.
7
 */
8
class m200730_065801_create_category_table extends Migration
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    public function safeUp()
14
    {
15
        $this->createTable('{{%category}}', [
16
            'id' => $this->primaryKey(),
17
            'user_id' => $this->integer()->notNull(),
18
            'direction' => $this->tinyInteger()->notNull(),
19
            'name' => $this->string(120)->notNull(),
20
            'color' => $this->string(7)->notNull(),
21
            'icon_name' => $this->string(120)->notNull(),
22
            'status' => $this->tinyInteger()->defaultValue(1),
23
            'created_at' => $this->timestamp()->defaultValue(null),
24
            'updated_at' => $this->timestamp()->defaultValue(null),
25
        ]);
26
27
        $this->createIndex('category_user_id', '{{%category}}', 'user_id');
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function safeDown()
34
    {
35
        $this->dropTable('{{%category}}');
36
    }
37
}
38