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

AddForeignKeysToTelegramUpdateTable::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A 0 8 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 AddForeignKeysToTelegramUpdateTable extends Migration
10
{
11
    public function up(): void
12
    {
13
        Schema::table('telegram_update', static function (Blueprint $table) {
14
            $table->foreign('chat_id', 'telegram_update_ibfk_1')->references('chat_id')->on('message')->onUpdate('RESTRICT')->onDelete('RESTRICT');
15
            $table->foreign('inline_query_id', 'telegram_update_ibfk_2')->references('id')->on('inline_query')->onUpdate('RESTRICT')->onDelete('RESTRICT');
16
            $table->foreign('chosen_inline_result_id', 'telegram_update_ibfk_3')->references('id')->on('chosen_inline_result')->onUpdate('RESTRICT')->onDelete('RESTRICT');
17
            $table->foreign('callback_query_id', 'telegram_update_ibfk_4')->references('id')->on('callback_query')->onUpdate('RESTRICT')->onDelete('RESTRICT');
18
            $table->foreign('edited_message_id', 'telegram_update_ibfk_5')->references('id')->on('edited_message')->onUpdate('RESTRICT')->onDelete('RESTRICT');
19
        });
20
    }
21
22
    public function down(): void
23
    {
24
        Schema::table('telegram_update', static function (Blueprint $table) {
25
            $table->dropForeign('telegram_update_ibfk_1');
26
            $table->dropForeign('telegram_update_ibfk_2');
27
            $table->dropForeign('telegram_update_ibfk_3');
28
            $table->dropForeign('telegram_update_ibfk_4');
29
            $table->dropForeign('telegram_update_ibfk_5');
30
        });
31
    }
32
}
33