m180627_121715_files::safeUp()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 25
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 25
rs 9.6
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
use yii\db\Migration;
4
5
class m180627_121715_files extends Migration
6
{
7
8
    public function safeUp()
9
    {
10
        $tableOptions = null;
11
        if ($this->db->driverName === 'mysql') {
12
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
13
        }
14
15
        $this->createTable(
16
            '{{%file}}',
17
            [
18
                'id' => $this->primaryKey(11),
19
                'class' => $this->string(255)->notNull(),
20
                'field' => $this->string(255)->notNull(),
21
                'object_id' => $this->integer(11)->notNull()->defaultValue(0),
22
                'title' => $this->string(255)->notNull(),
23
                'filename' => $this->string(255)->notNull(),
24
                'content_type' => $this->string(255)->notNull(),
25
                'type' => $this->integer(1)->notNull(),
26
                'video_status' => $this->integer(1)->null()->defaultValue(null),
27
                'ordering' => $this->integer(11)->notNull()->defaultValue(0),
28
                'created' => $this->integer(11)->notNull(),
29
                'user_id' => $this->integer(11)->null(),
30
                'size' => $this->integer(20)->notNull(),
31
                'hash' => $this->string(255)->null(),
32
            ], $tableOptions
33
        );
34
    }
35
36
    public function safeDown()
37
    {
38
39
        $this->dropTable('{{%file}}');
40
    }
41
}
42