Completed
Pull Request — master (#23)
by Armando
13:41
created

UpdateSchema0600To0610::up()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
dl 16
loc 16
rs 9.7333
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\Schema;
7
use PhpTelegramBot\Laravel\Migration;
8
9
class UpdateSchema0600To0610 extends Migration
10
{
11 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...
12
    {
13
        Schema::disableForeignKeyConstraints();
14
15
        try {
16
            Schema::table($this->prefix . 'telegram_update', static function (Blueprint $table) {
17
                $table->dropIndex('message_id');
18
                $table->index('message_id', 'message_id');
19
                $table->index(['chat_id', 'message_id'], 'chat_message_id');
20
            });
21
        } catch (Throwable $e) {
22
            return; // Migration may be partly done already...
23
        }
24
25
        Schema::enableForeignKeyConstraints();
26
    }
27
28 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...
29
    {
30
        Schema::disableForeignKeyConstraints();
31
32
        try {
33
            Schema::table($this->prefix . 'telegram_update', static function (Blueprint $table) {
34
                $table->dropIndex('chat_message_id');
35
                $table->dropIndex('message_id');
36
                $table->index('message_id', 'message_id');
37
            });
38
        } catch (Throwable $e) {
39
            return; // Migration may be partly done already...
40
        }
41
42
        Schema::enableForeignKeyConstraints();
43
    }
44
}
45