Passed
Push — tests ( 722676...5a1186 )
by Dallas
12:44
created

AddRelationsForFeatureTable2::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 11
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
use Illuminate\Database\Migrations\Migration;
6
use Illuminate\Database\Schema\Blueprint;
7
use Illuminate\Support\Facades\DB;
8
use Illuminate\Support\Facades\Schema;
9
10
class AddRelationsForFeatureTable2 extends Migration
11
{
12
    public function up(): void
13
    {
14
        DB::transaction(function () {
15
            Schema::table('feature_table2', function (Blueprint $table) {
16
                $table
17
                    ->bigInteger('feature_table3_id')
18
                    ->nullable(true);
19
                $table
20
                    ->foreign('feature_table3_id')
21
                    ->on('feature_table3')
22
                    ->references('id');
23
            });
24
        });
25
    }
26
27
    public function down(): void
28
    {
29
        DB::transaction(function () {
30
            Schema::table('feature_table2', function (Blueprint $table) {
31
                $table->dropColumn([
32
                    'feature_table3_id',
33
                ]);
34
            });
35
        });
36
    }
37
}
38