Passed
Branch master (3eb6ea)
by Anton
06:04
created

notifications_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
9
use yii\db\Migration;
10
11
class notifications_table extends Migration
0 ignored issues
show
Coding Style introduced by
Class name "notifications_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...
12
{
13
    public function up()
14
    {
15
        $this->createTable('notification', [
16
            'id' => $this->primaryKey(),
17
            'level' => $this->string(),
18
            'notifiable_type' => $this->string(),
19
            'notifiable_id' => $this->integer()->unsigned(),
20
            'subject' => $this->string(),
21
            'body' => $this->text(),
22
            'read_at' => $this->timestamp()->null(),
23
            'created_at' => $this->timestamp(),
24
            'updated_at' => $this->timestamp()->null(),
25
        ]);
26
        $this->createIndex('notifiable', 'notification', ['notifiable_type', 'notifiable_id']);
27
    }
28
29
    public function down()
30
    {
31
        $this->dropIndex('notifiable', 'notification');
32
        $this->dropTable('notification');
33
    }
34
35
}