CreateModulesWidgetsTable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 28 1
A down() 0 3 1
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Uccello\Core\Database\Migrations\Migration;
6
use Uccello\Core\Database\Migrations\Traits\TablePrefixTrait;
7
8
class CreateModulesWidgetsTable extends Migration
9
{
10
    use TablePrefixTrait;
11
12
    /**
13
     * Run the migrations.
14
     *
15
     * @return void
16
     */
17
    public function up()
18
    {
19
        Schema::create($this->tablePrefix.'modules_widgets', function(Blueprint $table) {
20
            $table->increments('id');
21
            $table->unsignedInteger('domain_id')->nullable();
22
            $table->unsignedInteger('module_id');
23
            $table->unsignedInteger('user_id')->nullable();
24
            $table->unsignedInteger('widget_id');
25
            $table->unsignedInteger('sequence');
26
            $table->text('data')->nullable();
27
            $table->timestamps();
28
29
            // Foreign keys
30
            $table->foreign('domain_id')
31
                ->references('id')->on($this->tablePrefix.'domains')
32
                ->onDelete('cascade');
33
34
            $table->foreign('module_id')
35
                ->references('id')->on($this->tablePrefix.'modules')
36
                ->onDelete('cascade');
37
38
            $table->foreign('user_id')
39
                ->references('id')->on('users')
40
                ->onDelete('cascade');
41
42
            $table->foreign('widget_id')
43
                ->references('id')->on($this->tablePrefix.'widgets')
44
                ->onDelete('cascade');
45
        });
46
    }
47
48
    /**
49
     * Reverse the migrations.
50
     *
51
     * @return void
52
     */
53
    public function down()
54
    {
55
        Schema::dropIfExists($this->tablePrefix.'modules_widgets');
56
    }
57
}
58