m150705_000002_create_dashboard_panel   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 14 2
A down() 0 5 1
1
<?php
2
3
use yii\db\Schema;
4
5
class m150705_000002_create_dashboard_panel extends \yii\db\Migration
6
{
7
    const TABLE = '{{%dashboard_panel}}';
8
9
    public function up()
10
    {
11
        $this->createTable(self::TABLE, [
12
            'id' => Schema::TYPE_PK,
13
            'name' => Schema::TYPE_STRING . ' NOT NULL',
14
            'panel_class' => Schema::TYPE_STRING . ' NOT NULL',
15
            'options' => Schema::TYPE_TEXT,
16
            'dashboard_id' => Schema::TYPE_INTEGER . ' NOT NULL',
17
            'region' => Schema::TYPE_STRING . ' NOT NULL',
18
            'sort' => Schema::TYPE_INTEGER . ' NOT NULL',
19
            'enabled' => Schema::TYPE_INTEGER . '(1) DEFAULT 0 NOT NULL',
20
        ], ($this->db->driverName === 'mysql' ? 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB' : null));
21
        $this->addForeignKey('fk_dashboard_panel_dashboard_id', self::TABLE, ['dashboard_id'], '{{%dashboard}}', 'id', 'CASCADE');
22
    }
23
24
    public function down()
25
    {
26
        $this->dropForeignKey('fk_dashboard_panel_dashboard_id', self::TABLE);
27
        $this->dropTable(self::TABLE);
28
    }
29
}
30