Passed
Push — master ( c36ed8...8867a0 )
by Quentin
13:25 queued 05:48
created

CreateRelatedTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 32
rs 10
wmc 2
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6
7
class CreateRelatedTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('related', function (Blueprint $table) {
17
            $table->integer('subject_id')->nullable()->unsigned();
18
            $table->string('subject_type', 255);
19
            $table->integer('related_id')->nullable()->unsigned();
20
            $table->string('related_type', 255);
21
            $table->string('browser_name')->index();
22
            $table->integer('position')->unsigned();
23
24
            $table->unique(
25
                ['subject_id', 'subject_type', 'related_id', 'related_type', 'browser_name'],
26
                'related_unique'
27
            );
28
        });
29
    }
30
31
    /**
32
     * Reverse the migrations.
33
     *
34
     * @return void
35
     */
36
    public function down()
37
    {
38
        Schema::dropIfExists('related');
39
    }
40
}
41