m180111_102503_create_media_stats_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_stats`.
7
 */
8
class m180111_102503_create_media_stats_table extends Migration
9
{
10
    /**
11
     * @inheritdoc
12
     */
13
    public function up()
14
    {
15
        $this->createTable('media_stats', [
16
            'id' => $this->primaryKey(),
17
            'media_id' => $this->integer(),
18
            'likes' => $this->integer(),
19
            'comments' => $this->integer(),
20
            'account_followed_by' => $this->integer(),
21
            'account_follows' => $this->integer(),
22
            'created_at' => $this->dateTime(),
23
        ]);
24
25
        $this->addForeignKey('fk_media_stats_media', 'media_stats', 'media_id', 'media', 'id', 'CASCADE');
26
    }
27
28
    /**
29
     * @inheritdoc
30
     */
31
    public function down()
32
    {
33
        $this->dropForeignKey('fk_media_stats_media', 'media_stats');
34
        $this->dropTable('media_stats');
35
    }
36
}
37