m161031_092433_create_flow_table::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Handles the creation of table `flow`.
7
 */
8
// @codingStandardsIgnoreLine
9 View Code Duplication
class m161031_092433_create_flow_table extends Migration
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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('flow', [
22
            'id' => $this->primaryKey()->notNull()->append('AUTO_INCREMENT'),
23
            'name' => $this->string(64)->notNull(),
24
            'description' => $this->string(1024),
25
            'parent_id' => $this->integer(),
26
        ], $tableOptions);
27
28
        $this->createIndex(
29
            'fk_flow_flow1_idx',
30
            'flow',
31
            'parent_id'
32
        );
33
34
        $this->addForeignKey(
35
            'fk_flow_flow1',
36
            'flow',
37
            'parent_id',
38
            'flow',
39
            'id',
40
            'SET NULL',
41
            'SET NULL'
42
        );
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function down()
49
    {
50
        $this->dropTable('flow');
51
    }
52
}
53