Completed
Push — master ( f45cc5...2edd5b )
by Igor
05:32
created

safeUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 2
eloc 10
nc 2
nop 0
1
<?php
2
3
use yii\db\Schema;
4
5
class m161026_103038_create_user_profiles_files extends \yii\db\Migration
6
{
7
    public function safeUp()
8
    {
9
        $tableOptions = null;
10
        if ($this->db->driverName === 'mysql') {
11
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
12
        }
13
14
        $this->createTable('{{%user_profiles_files}}', [
15
            'id' => Schema::TYPE_PK,
16
            'user_id' => Schema::TYPE_INTEGER . " NOT NULL DEFAULT 0",
17
            'file_id' => Schema::TYPE_INTEGER . " NOT NULL DEFAULT 0",
18
        ], $tableOptions);
19
20
        $this->createIndex('link', '{{%user_profiles_files}}', 'user_id, file_id');
21
    }
22
23
    public function safeDown()
24
    {
25
        $this->dropTable('{{%user_profiles_files}}');
26
    }
27
}
28