m180111_102503_create_media_stats_table   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 27
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 4 1
A up() 0 13 1
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