Completed
Pull Request — master (#23)
by Armando
15:35
created

UpdateSchema0600To0610::up()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17

Duplication

Lines 17
Ratio 100 %

Importance

Changes 0
Metric Value
dl 17
loc 17
rs 9.7
c 0
b 0
f 0
cc 2
nc 2
nop 0
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 UpdateSchema0600To0610 extends Migration
11
{
12 View Code Duplication
    public function up(): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
    {
14
        Schema::disableForeignKeyConstraints();
15
16
        try {
17
            Schema::table($this->prefix . 'telegram_update', static function (Blueprint $table) {
18
                $table->dropIndex('message_id');
19
                $table->index('message_id', 'message_id');
20
                $table->index(['chat_id', 'message_id'], 'chat_message_id');
21
            });
22
        } catch (Throwable $e) {
23
            Log::error($e->getMessage());
24
            return; // Migration may be partly done already...
25
        }
26
27
        Schema::enableForeignKeyConstraints();
28
    }
29
30 View Code Duplication
    public function down(): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
    {
32
        Schema::disableForeignKeyConstraints();
33
34
        try {
35
            Schema::table($this->prefix . 'telegram_update', static function (Blueprint $table) {
36
                $table->dropIndex('chat_message_id');
37
                $table->dropIndex('message_id');
38
                $table->index('message_id', 'message_id');
39
            });
40
        } catch (Throwable $e) {
41
            Log::error($e->getMessage());
42
            return; // Migration may be partly done already...
43
        }
44
45
        Schema::enableForeignKeyConstraints();
46
    }
47
}
48