m161031_104500_create_field_table   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
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 48
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 34 2
A down() 0 4 1
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Handles the creation of table `field`.
7
 */
8
// @codingStandardsIgnoreLine
9
class m161031_104500_create_field_table extends Migration
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function up()
15
    {
16
        $tableOptions = null;
17
        if ($this->db->driverName === 'mysql') {
18
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
19
        }
20
21
        $this->createTable('field', [
22
            'id' => $this->primaryKey()->notNull()->append('AUTO_INCREMENT'),
23
            'template_id' => $this->integer()->notNull(),
24
            'x1' => $this->float()->notNull(),
25
            'y1' => $this->float()->notNull(),
26
            'x2' => $this->float()->notNull(),
27
            'y2' => $this->float()->notNull(),
28
            'css' => $this->text(),
29
            'js' => $this->text(),
30
        ], $tableOptions);
31
32
        $this->createIndex(
33
            'fk_field_template1_idx',
34
            'field',
35
            'template_id'
36
        );
37
38
        $this->addForeignKey(
39
            'fk_field_template1',
40
            'field',
41
            'template_id',
42
            'screen_template',
43
            'id',
44
            'CASCADE',
45
            'CASCADE'
46
        );
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function down()
53
    {
54
        $this->dropTable('field');
55
    }
56
}
57