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

UpdateSchema0640To0700::up()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 12
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
use Illuminate\Database\Schema\Blueprint;
6
use Illuminate\Support\Facades\Log;
7
use Illuminate\Support\Facades\Schema;
8
use PhpTelegramBot\Laravel\Migration;
9
10
class UpdateSchema0640To0700 extends Migration
11
{
12
    public function up(): void
13
    {
14
        try {
15
            $this->changeColumnTypes(['poll' => ['question']], 'text');
16
17
            Schema::table($this->prefix . 'message', static function (Blueprint $table) {
18
                $table->bigInteger('sender_chat_id')->comment('Sender of the message, sent on behalf of a chat')->after('chat_id');
19
                $table->text('proximity_alert_triggered')->nullable()->comment('Service message. A user in the chat triggered another user\'s proximity alert while sharing Live Location.')->after('passport_data');
20
            });
21
        } catch (Throwable $e) {
22
            Log::error($e->getMessage());
23
            return; // Migration may be partly done already...
24
        }
25
    }
26
27
    public function down(): void
28
    {
29
        try {
30
            Schema::table($this->prefix . 'message', static function (Blueprint $table) {
31
                $table->dropColumn('proximity_alert_triggered');
32
                $table->dropColumn('sender_chat_id');
33
            });
34
35
            $this->changeColumnTypes(['poll' => ['question']], 'char(255)');
36
        } catch (Throwable $e) {
37
            Log::error($e->getMessage());
38
            return; // Migration may be partly done already...
39
        }
40
    }
41
}
42