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

UpdateCallbackQueryTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 16 1
A down() 0 13 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 UpdateCallbackQueryTable extends Migration
9
{
10
    public function up ()
11
    {
12
        Schema::table(config('phptelegrambot.database.prefix', '') . 'callback_query', static function (Blueprint $table) {
13
            $table->char ('chat_instance', 255)->after('inline_message_id')->default('')->comment ('Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent');
14
            $table->char ('game_short_name', 255)->after('data')->default('')->comment ('Short name of a Game to be returned, serves as the unique identifier for the game');
15
16
            $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'callback_query_ibfk_2');
17
18
            $table->foreign (
19
                ['chat_id', 'message_id'],
20
                config('phptelegrambot.database.prefix', '') . 'callback_query_ibfk_2'
21
            )
22
                ->references (['chat_id', 'id'])->on (config('phptelegrambot.database.prefix', '') . 'message')
23
                ->onUpdate('RESTRICT')->onDelete('RESTRICT');
24
        });
25
    }
26
27
    public function down ()
28
    {
29
        Schema::table(config('phptelegrambot.database.prefix', '') . 'callback_query', static function (Blueprint $table) {
30
            $table->dropColumn ('chat_instance');
31
            $table->dropColumn ('game_short_name');
32
33
            $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'callback_query_ibfk_2');
34
35
            $table->foreign ('chat_id', config('phptelegrambot.database.prefix', '') . 'callback_query_ibfk_2')
36
                ->references ('chat_id')->on (config('phptelegrambot.database.prefix', '') . 'message')
37
                ->onUpdate('RESTRICT')->onDelete('RESTRICT');
38
        });
39
    }
40
}
41