AddForeignKeysToEditedMessageTable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 17
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 6 1
A up() 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\Schema;
8
9
class AddForeignKeysToEditedMessageTable extends Migration
10
{
11
    public function up(): void
12
    {
13
        Schema::table('edited_message', static function (Blueprint $table) {
14
            $table->foreign('chat_id', 'edited_message_ibfk_1')->references('id')->on('chat')->onUpdate('RESTRICT')->onDelete('RESTRICT');
15
            $table->foreign('chat_id', 'edited_message_ibfk_2')->references('chat_id')->on('message')->onUpdate('RESTRICT')->onDelete('RESTRICT');
16
            $table->foreign('user_id', 'edited_message_ibfk_3')->references('id')->on('user')->onUpdate('RESTRICT')->onDelete('RESTRICT');
17
        });
18
    }
19
20
    public function down(): void
21
    {
22
        Schema::table('edited_message', static function (Blueprint $table) {
23
            $table->dropForeign('edited_message_ibfk_1');
24
            $table->dropForeign('edited_message_ibfk_2');
25
            $table->dropForeign('edited_message_ibfk_3');
26
        });
27
    }
28
}
29