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

AddRelationsForFeatureTable1   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 14
dl 0
loc 23
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 11 1
A down() 0 6 1
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 AddRelationsForFeatureTable1 extends Migration
11
{
12
    public function up(): void
13
    {
14
        DB::transaction(function () {
15
            Schema::table('feature_table1', function (Blueprint $table) {
16
                $table
17
                    ->bigInteger('feature_table2_id')
18
                    ->nullable(true);
19
                $table
20
                    ->foreign('feature_table2_id')
21
                    ->on('feature_table2')
22
                    ->references('id');
23
            });
24
        });
25
    }
26
27
    public function down(): void
28
    {
29
        DB::transaction(function () {
30
            Schema::table('feature_table1', function (Blueprint $table) {
31
                $table->dropColumn([
32
                    'feature_table2_id',
33
                ]);
34
            });
35
        });
36
    }
37
}
38