FixAgentName   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A migrateUp() 0 27 2
A migrateDown() 0 13 2
1
<?php
2
3
use PragmaRX\Tracker\Support\Migration;
4
5
class FixAgentName extends Migration
6
{
7
    /**
8
     * Table related to this migration.
9
     *
10
     * @var string
11
     */
12
    private $table = 'tracker_agents';
13
14
    /**
15
     * Run the migrations.
16
     *
17
     * @return void
18
     */
19
    public function migrateUp()
20
    {
21
        try {
22
            $this->builder->table(
23
                $this->table,
24
                function ($table) {
25
                    $table->dropUnique('tracker_agents_name_unique');
26
                }
27
            );
28
29
            $this->builder->table(
30
                $this->table,
31
                function ($table) {
32
                    $table->mediumText('name')->change();
33
                }
34
            );
35
36
            $this->builder->table(
37
                $this->table,
38
                function ($table) {
39
                    $table->unique('id', 'tracker_agents_name_unique'); // this is a dummy index
40
                }
41
            );
42
        } catch (\Exception $e) {
43
            dd($e->getMessage());
44
        }
45
    }
46
47
    /**
48
     * Reverse the migrations.
49
     *
50
     * @return void
51
     */
52
    public function migrateDown()
53
    {
54
        try {
55
            $this->builder->table(
56
                $this->table,
57
                function ($table) {
58
                    $table->string('name', 255)->change();
59
                    $table->unique('name');
60
                }
61
            );
62
        } catch (\Exception $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
63
        }
64
    }
65
}
66