m140602_111327_create_menu_table::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
c 1
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
use toir427\admin\components\Configs;
4
5
/**
6
 * Migration table of table_menu
7
 * 
8
 * @author Misbahul D Munir <[email protected]>
9
 * @since 1.0
10
 */
11
class m140602_111327_create_menu_table extends \yii\db\Migration
12
{
13
14
    /**
15
     * @inheritdoc
16
     */
17
    public function up()
18
    {
19
        $menuTable = Configs::instance()->menuTable;
20
        $tableOptions = null;
21
        if ($this->db->driverName === 'mysql') {
22
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
23
        }
24
25
        $this->createTable($menuTable, [
26
            'id' => $this->primaryKey(),
27
            'name' => $this->string(128)->notNull(),
28
            'parent' => $this->integer(),
29
            'route' => $this->string(),
30
            'order' => $this->integer(),
31
            'data' => $this->binary(),
32
            "FOREIGN KEY ([[parent]]) REFERENCES {$menuTable}([[id]]) ON DELETE SET NULL ON UPDATE CASCADE",
33
        ], $tableOptions);
34
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39
    public function down()
40
    {
41
        $this->dropTable(Configs::instance()->menuTable);
42
    }
43
}
44