m000000_000017_media_comment::up()   B
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 19

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 24
rs 8.9713
cc 2
eloc 19
nc 2
nop 0
1
<?php
2
3
use yii\db\Schema;
4
5
/**
6
 * Class m000000_000017_media_comment
7
 *
8
 * @author Agiel K. Saputra <[email protected]>
9
 * @since 0.1.0
10
 */
11
class m000000_000017_media_comment extends \yii\db\Migration
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
12
{
13
    /**
14
     * @inheritdoc
15
     */
16
    public function up()
17
    {
18
        $tableOptions = null;
19
20
        if ($this->db->driverName === 'mysql') {
21
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
22
        }
23
24
        $this->createTable('{{%media_comment}}', [
25
            'id' => Schema::TYPE_PK,
26
            'media_id' => Schema::TYPE_INTEGER . '(11) NOT NULL',
27
            'author' => Schema::TYPE_TEXT,
28
            'email' => Schema::TYPE_STRING . '(100)',
29
            'url' => Schema::TYPE_STRING . '(255)',
30
            'ip' => Schema::TYPE_STRING . '(100) NOT NULL',
31
            'date' => Schema::TYPE_DATETIME . ' NOT NULL',
32
            'content' => Schema::TYPE_TEXT . ' NOT NULL',
33
            'status' => Schema::TYPE_STRING . '(20) NOT NULL',
34
            'agent' => Schema::TYPE_STRING . '(255) NOT NULL',
35
            'parent' => Schema::TYPE_INTEGER . '(11) DEFAULT 0',
36
            'user_id' => Schema::TYPE_INTEGER . '(11)',
37
            'FOREIGN KEY ([[media_id]]) REFERENCES {{%media}} ([[id]]) ON DELETE CASCADE ON UPDATE CASCADE',
38
        ], $tableOptions);
39
    }
40
41
    /**
42
     * @inheritdoc
43
     */
44
    public function down()
45
    {
46
        $this->dropTable('{{%media_comment}}');
47
    }
48
}
49