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

UpdateEditedMessageTable::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
<?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