Completed
Push — master ( 2d0bf2...b0eeab )
by Renato
20:37 queued 18:12
created

AddForeignKeysToLabelablesTable::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
6
class AddForeignKeysToLabelablesTable extends Migration
7
{
8
    /**
9
     * Run the migrations.
10
     */
11
    public function up()
12
    {
13
        Schema::table('labelables', function (Blueprint $table) {
14
            $table->foreign('label_id', 'fk_labelables_label_id')->references('id')->on('labels')->onUpdate('NO ACTION')->onDelete('NO ACTION');
15
            $table->foreign('user_id', 'fk_labelables_user_id')->references('id')->on('users')->onUpdate('NO ACTION')->onDelete('NO ACTION');
16
        });
17
    }
18
19
    /**
20
     * Reverse the migrations.
21
     */
22
    public function down()
23
    {
24
        Schema::table('labelables', function (Blueprint $table) {
25
            $table->dropForeign('fk_labelables_label_id');
26
            $table->dropForeign('fk_labelables_user_id');
27
        });
28
    }
29
}
30