m180111_102457_create_media_table::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Handles the creation of table `media`.
7
 */
8
class m180111_102457_create_media_table extends Migration
9
{
10
    /**
11
     * @inheritdoc
12
     */
13
    public function up()
14
    {
15
        $this->createTable('media', [
16
            'id' => $this->primaryKey(),
17
            'account_id' => $this->integer(),
18
            'shortcode' => $this->string()->notNull()->unique(),
19
            'is_video' => $this->boolean(),
20
            'caption' => $this->text(),
21
            'instagram_id' => $this->string(),
22
            'taken_at' => $this->dateTime(),
23
            'updated_at' => $this->dateTime(),
24
            'created_at' => $this->dateTime(),
25
            'monitoring' => $this->boolean()->notNull()->defaultValue(0),
26
        ]);
27
28
        $this->addForeignKey('fk_media_account', 'media', 'account_id', 'account', 'id', 'CASCADE');
29
    }
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function down()
35
    {
36
        $this->dropForeignKey('fk_media_account', 'media');
37
        $this->dropTable('media');
38
    }
39
}
40