Completed
Push — master ( 32dcc3...b50c12 )
by Jonathan
14:17 queued 06:25
created

CreateModulesWidgetsTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
c 1
b 0
f 0
dl 0
loc 47
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 27 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->text('data')->nullable();
26
            $table->timestamps();
27
28
            // Foreign keys
29
            $table->foreign('domain_id')
30
                ->references('id')->on($this->tablePrefix.'domains')
31
                ->onDelete('cascade');
32
33
            $table->foreign('module_id')
34
                ->references('id')->on($this->tablePrefix.'modules')
35
                ->onDelete('cascade');
36
37
            $table->foreign('user_id')
38
                ->references('id')->on('users')
39
                ->onDelete('cascade');
40
41
            $table->foreign('widget_id')
42
                ->references('id')->on($this->tablePrefix.'widgets')
43
                ->onDelete('cascade');
44
        });
45
    }
46
47
    /**
48
     * Reverse the migrations.
49
     *
50
     * @return void
51
     */
52
    public function down()
53
    {
54
        Schema::dropIfExists($this->tablePrefix.'modules_widgets');
55
    }
56
}
57