CreateEntitiesTable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 15
c 1
b 0
f 0
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 21 1
A down() 0 3 1
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Uccello\Core\Database\Migrations\Migration;
6
7
class CreateEntitiesTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create($this->tablePrefix.'entities', function (Blueprint $table) {
17
            $table->uuid('id')->primary();
18
            $table->unsignedInteger('module_id');
19
            $table->unsignedInteger('record_id');
20
            $table->unsignedInteger('creator_id')->nullable();
21
            $table->timestamps();
22
23
            $table->index('module_id', 'record_id');
24
25
            // Foreign keys
26
            $table->foreign('module_id')
27
                ->references('id')->on($this->tablePrefix.'modules')
28
                ->onDelete('cascade');
29
30
            $table->foreign('creator_id')
31
                ->references('id')->on('users');
32
33
            // Index
34
            $table->index(array('module_id', 'creator_id'));
35
        });
36
    }
37
38
    /**
39
     * Reverse the migrations.
40
     *
41
     * @return void
42
     */
43
    public function down()
44
    {
45
        Schema::dropIfExists($this->tablePrefix.'entities');
46
    }
47
}
48