m161031_093304_create_user_has_flow_table::up()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 50

Duplication

Lines 50
Ratio 100 %

Importance

Changes 0
Metric Value
dl 50
loc 50
rs 9.0909
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Handles the creation of table `user_has_flow`.
7
 */
8
// @codingStandardsIgnoreLine
9 View Code Duplication
class m161031_093304_create_user_has_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('user_has_flow', [
22
            'user_username' => $this->string(64)->notNull(),
23
            'flow_id' => $this->integer()->notNull(),
24
        ], $tableOptions);
25
26
        $this->addPrimaryKey(
27
            'pk_user_has_flow',
28
            'user_has_flow',
29
            ['user_username', 'flow_id']
30
        );
31
32
        $this->createIndex(
33
            'fk_user_has_flow_flow1_idx',
34
            'user_has_flow',
35
            'flow_id'
36
        );
37
38
        $this->createIndex(
39
            'fk_user_has_flow_user1_idx',
40
            'user_has_flow',
41
            'user_username'
42
        );
43
44
        $this->addForeignKey(
45
            'fk_user_has_flow_user1',
46
            'user_has_flow',
47
            'user_username',
48
            'user',
49
            'username',
50
            'CASCADE',
51
            'CASCADE'
52
        );
53
54
        $this->addForeignKey(
55
            'fk_user_has_flow_flow1',
56
            'user_has_flow',
57
            'flow_id',
58
            'flow',
59
            'id',
60
            'CASCADE',
61
            'CASCADE'
62
        );
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function down()
69
    {
70
        $this->dropTable('user_has_flow');
71
    }
72
}
73