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

UpdateSchema0600To0610   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 88.89 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 32
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 16 16 2
A down() 16 16 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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