AlterGroupsTable::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
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;
4
use Illuminate\Database\Schema\Blueprint;
5
use Uccello\Core\Database\Migrations\Migration;
6
7
class AlterGroupsTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::table($this->tablePrefix.'groups', function(Blueprint $table) {
17
            $table->unsignedInteger('domain_id')->nullable()->after('description');
18
19
            // Foreign keys
20
            $table->foreign('domain_id')->references('id')->on($this->tablePrefix.'domains');
21
        });
22
    }
23
24
    /**
25
     * Reverse the migrations.
26
     *
27
     * @return void
28
     */
29
    public function down()
30
    {
31
        Schema::table($this->tablePrefix.'groups', function(Blueprint $table) {
32
            $table->dropForeign($this->tablePrefix.'groups_domain_id_foreign');
33
34
            $table->dropColumn('domain_id');
35
        });
36
    }
37
}
38