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

m180824_090744_create_notification_table::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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
}