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

m161026_103038_create_user_profiles_files   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeUp() 0 15 2
A safeDown() 0 4 1
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