Completed
Pull Request — master (#24)
by
unknown
11:40 queued 10s
created

UpdateEditedMessageTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 13 1
A down() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
use Illuminate\Database\Migrations\Migration;
6
use Illuminate\Database\Schema\Blueprint;
7
8
class UpdateEditedMessageTable extends Migration
9
{
10
    public function up ()
11
    {
12
        Schema::table(config('phptelegrambot.database.prefix', '') . 'edited_message', static function (Blueprint $table) {
13
            $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'edited_message_ibfk_2');
14
15
            $table->foreign (
16
                ['chat_id', 'message_id'],
17
                config('phptelegrambot.database.prefix', '') . 'edited_message_ibfk_2'
18
            )
19
                ->references (['chat_id', 'id'])->on (config('phptelegrambot.database.prefix', '') . 'message')
20
                ->onUpdate('RESTRICT')->onDelete('RESTRICT');
21
        });
22
    }
23
24
    public function down ()
25
    {
26
        Schema::table(config('phptelegrambot.database.prefix', '') . 'edited_message', static function (Blueprint $table) {
27
            $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'edited_message_ibfk_2');
28
29
            $table->foreign ('chat_id', config('phptelegrambot.database.prefix', '') . 'edited_message_ibfk_2')
30
                ->references ('chat_id')->on (config('phptelegrambot.database.prefix', '') . 'message')
31
                ->onUpdate('RESTRICT')->onDelete('RESTRICT');
32
        });
33
    }
34
}
35