Passed
Push — master ( 7c331b...3c78de )
by Jonathan
18:06
created

AlterRolesTable::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
0 ignored issues
show
Bug introduced by
The type Illuminate\Support\Facades\Schema was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
4
use Illuminate\Database\Schema\Blueprint;
0 ignored issues
show
Bug introduced by
The type Illuminate\Database\Schema\Blueprint was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
5
use Uccello\Core\Database\Migrations\Migration;
6
7
class AlterRolesTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        if (
17
            !Schema::hasColumn($this->tablePrefix.'roles', 'path')
18
            && !Schema::hasColumn($this->tablePrefix.'roles', 'level')
19
        ) {
20
            Schema::table($this->tablePrefix.'roles', function(Blueprint $table) {
21
                $table->string('path')->nullable()->after('parent_id');
22
                $table->integer('level')->default(0)->after('path');
23
24
                // Index
25
                $table->index(array('path', 'parent_id', 'level'));
26
            });
27
        }
28
    }
29
30
    /**
31
     * Reverse the migrations.
32
     *
33
     * @return void
34
     */
35
    public function down()
36
    {
37
        Schema::table($this->tablePrefix.'roles', function(Blueprint $table) {
38
            $table->dropIndex($this->tablePrefix.'roles_path_parent_id_level_index');
39
40
            $table->dropColumn('path');
41
            $table->dropColumn('level');
42
        });
43
    }
44
}
45