m200730_065801_create_category_table   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeDown() 0 3 1
A safeUp() 0 15 1
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