Passed
Push — master ( d10f8f...520379 )
by Anton
04:13
created

m180824_090744_create_notification_table   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 14
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 4 1
A up() 0 14 1
1
<?php
2
/**
3
 * @copyright Anton Tuyakhov <[email protected]>
4
 */
5
6
namespace tuyakhov\notifications\migrations;
7
8
use yii\db\Migration;
9
10
class m180824_090744_create_notification_table extends Migration
0 ignored issues
show
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...
11
{
12
    public function up()
13
    {
14
        $this->createTable('notification', [
15
            'id' => $this->primaryKey(),
16
            'level' => $this->string(),
17
            'notifiable_type' => $this->string(),
18
            'notifiable_id' => $this->integer()->unsigned(),
19
            'subject' => $this->string(),
20
            'body' => $this->text(),
21
            'read_at' => $this->timestamp()->null(),
22
            'created_at' => $this->timestamp()->defaultExpression('CURRENT_TIMESTAMP'),
23
            'updated_at' => $this->timestamp()->null(),
24
        ]);
25
        $this->createIndex('notifiable', 'notification', ['notifiable_type', 'notifiable_id']);
26
    }
27
28
    public function down()
29
    {
30
        $this->dropIndex('notifiable', 'notification');
31
        $this->dropTable('notification');
32
    }
33
34
}