Passed
Push — dependabot/npm_and_yarn/string... ( b56eb5...bc569b )
by
unknown
45:46 queued 33s
created

AddRelationsTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 2
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class AddRelationsTable extends Migration
8
{
9
    public function up()
10
    {
11
        Schema::create('relations', function (Blueprint $table) {
12
            $table->string("parent_type");
13
            $table->unsignedBigInteger("parent_id");
14
            $table->string("child_type");
15
            $table->unsignedBigInteger("child_id");
16
17
            $table->tinyInteger('sort')->default(0);
18
19
            $table->index(["parent_type", "parent_id"], 'parent_index');
20
            $table->index(["child_type", "child_id"], 'child_index');
21
22
            $table->primary(["parent_type", "parent_id", "child_type", "child_id"]);
23
        });
24
    }
25
26
    public function down()
27
    {
28
        Schema::dropIfExists('relations');
29
    }
30
}
31