CreateAliveMessagesTable::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 47
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 47
rs 9.0303
c 0
b 0
f 0
cc 1
eloc 31
nc 1
nop 0
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class CreateAliveMessagesTable 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...
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('alive_messages', function (Blueprint $table) {
17
            $table->increments('id');
18
19
            // From field
20
            $table->unsignedInteger('from')
21
                ->nullable()
22
                ->index();
23
24
            $table->foreign('from')
25
                ->references('id')
26
                ->on('users')
27
                ->onDelete('cascade')
28
                ->onUpdate('cascade');
29
30
            // To field
31
            $table->unsignedInteger('to')
32
                ->nullable()
33
                ->index();
34
35
            $table->foreign('to')
36
                ->references('id')
37
                ->on('users')
38
                ->onDelete('cascade')
39
                ->onUpdate('cascade');
40
41
            $table->string('body')
42
                ->nullable();
43
44
            // to show message or not
45
            $table->boolean('invisible')
46
                ->default(false);
47
48
            // Process field
49
            $table->unsignedInteger('process_id')
50
                ->index();
51
52
            $table->foreign('process_id')
53
                ->references('id')
54
                ->on('alive_message_processes')
55
                ->onDelete('cascade')
56
                ->onUpdate('cascade');
57
58
            $table->timestamps();
59
        });
60
    }
61
62
    /**
63
     * Reverse the migrations.
64
     *
65
     * @return void
66
     */
67
    public function down()
68
    {
69
        Schema::dropIfExists('alive_messages');
70
    }
71
}
72