Passed
Push — master ( fde606...0af3c0 )
by Armando
08:21
created

AddForeignKeysToCallbackQueryTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 18
loc 18
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 5 1
A up() 0 5 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Schema;
8
9
class AddForeignKeysToCallbackQueryTable extends Migration
10
{
11
    public function up(): void
12
    {
13
        Schema::table('callback_query', static function (Blueprint $table) {
14
            $table->foreign('user_id', 'callback_query_ibfk_1')->references('id')->on('user')->onUpdate('RESTRICT')->onDelete('RESTRICT');
15
            $table->foreign('chat_id', 'callback_query_ibfk_2')->references('chat_id')->on('message')->onUpdate('RESTRICT')->onDelete('RESTRICT');
16
        });
17
    }
18
19
    public function down(): void
20
    {
21
        Schema::table('callback_query', static function (Blueprint $table) {
22
            $table->dropForeign('callback_query_ibfk_1');
23
            $table->dropForeign('callback_query_ibfk_2');
24
        });
25
    }
26
}
27