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

AlterEntitiesTable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 8 2
A down() 0 6 1
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 AlterEntitiesTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        if (!Schema::hasColumn($this->tablePrefix.'entities', 'creator_id')) {
17
            Schema::table($this->tablePrefix.'entities', function(Blueprint $table) {
18
                $table->unsignedInteger('creator_id')->nullable()->after('record_id');
19
20
                // Foreign keys
21
                $table->foreign('creator_id')->references('id')->on('users');
22
            });
23
        }
24
    }
25
26
    /**
27
     * Reverse the migrations.
28
     *
29
     * @return void
30
     */
31
    public function down()
32
    {
33
        Schema::table($this->tablePrefix.'entities', function(Blueprint $table) {
34
            $table->dropForeign($this->tablePrefix.'entities_creator_id_foreign');
35
36
            $table->dropColumn('creator_id');
37
        });
38
    }
39
}
40