Passed
Push — master ( 5fae26...4637e9 )
by Anton
03:55
created

m180824_090744_create_notification_table::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
c 0
b 0
f 0
dl 0
loc 14
rs 9.9
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * @copyright Anton Tuyakhov <[email protected]>
4
 */
5
6
use yii\db\Migration;
7
8
class m180824_090744_create_notification_table extends 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...
Coding Style introduced by
Class name "m180824_090744_create_notification_table" is not in StudlyCaps format

Classes in PHP are usually named in CamelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.

Thus the name database provider becomes DatabaseProvider.

Loading history...
9
{
10
    public function up()
11
    {
12
        $this->createTable('notification', [
13
            'id' => $this->primaryKey(),
14
            'level' => $this->string(),
15
            'notifiable_type' => $this->string(),
16
            'notifiable_id' => $this->integer()->unsigned(),
17
            'subject' => $this->string(),
18
            'body' => $this->text(),
19
            'read_at' => $this->timestamp()->null(),
20
            'created_at' => $this->timestamp(),
21
            'updated_at' => $this->timestamp()->null(),
22
        ]);
23
        $this->createIndex('notifiable', 'notification', ['notifiable_type', 'notifiable_id']);
24
    }
25
26
    public function down()
27
    {
28
        $this->dropIndex('notifiable', 'notification');
29
        $this->dropTable('notification');
30
    }
31
32
}