m161128_081820_create_lookup_table   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 19 2
A down() 0 4 1
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Handles the creation of table `lookup`.
7
 */
8
class m161128_081820_create_lookup_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('{{%lookup}}', [
20
            'id' => $this->primaryKey(),
21
            'type' => $this->string(100)->notNull(),
22
            'name' => $this->string(100)->notNull(),
23
            'code' => $this->integer()->defaultValue(1)->notNull(),
24
            'comment' => $this->text(),
25
            'active' => $this->boolean()->defaultValue(1),
26
            'order' => $this->integer()->defaultValue(1)->notNull(),
27
            'created_at' => $this->integer()->defaultValue(null)->notNull(),
28
            'updated_at' => $this->integer()->defaultValue(null)
29
        ], $tableOptions);
30
        $this->createIndex('lookup_type_name', '{{%lookup}}', ['type', 'name']);
31
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36
    public function down()
37
    {
38
        $this->dropTable('{{%lookup}}');
39
    }
40
}
41