safeUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
use app\migrations\Migration;
4
5
class m141230_043249_create_user_profile_to_file extends Migration
6
{
7
    public function safeUp()
8
    {
9
        $this->createTable('{{%user_profile_to_file}}', [
10
            'id' => $this->primaryKey(),
11
            'user_id' => $this->integer()->notNull()->defaultValue(0),
12
            'file_id' => $this->integer()->notNull()->defaultValue(0),
13
        ], $this->tableOptions);
14
15
        $this->createIndex('link', '{{%user_profile_to_file}}', 'user_id, file_id');
16
17
        $this->addForeignKey(
18
            'fk_user_profile_to_file__user_id__user_id',
19
            '{{%user_profile_to_file}}',
20
            'user_id',
21
            '{{%user}}',
22
            'id',
23
            'CASCADE',
24
            'CASCADE'
25
        );
26
    }
27
28
    public function safeDown()
29
    {
30
        $this->dropTable('{{%user_profile_to_file}}');
31
    }
32
}
33