CreateFiltersTable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 47
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 3 1
A up() 0 29 1
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 CreateFiltersTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create($this->tablePrefix.'filters', function(Blueprint $table) {
17
            $table->increments('id');
18
            $table->unsignedInteger('module_id');
19
            $table->unsignedInteger('domain_id')->nullable();
20
            $table->unsignedInteger('user_id')->nullable();
21
            $table->string('name');
22
            $table->string('type');
23
            $table->text('columns');
24
            $table->text('conditions')->nullable();
25
            $table->string('order_by')->nullable();
26
            $table->boolean('is_default')->default(false);
27
            $table->boolean('is_public')->default(false);
28
            $table->text('data')->nullable();
29
            $table->timestamps();
30
31
            // Foreign keys
32
            $table->foreign('module_id')
33
                    ->references('id')->on($this->tablePrefix.'modules')
34
                    ->onDelete('cascade');
35
36
            $table->foreign('domain_id')
37
                    ->references('id')->on($this->tablePrefix.'domains')
38
                    ->onDelete('cascade');
39
40
            $table->foreign('user_id')
41
                    ->references('id')->on('users')
42
                    ->onDelete('cascade');
43
        });
44
    }
45
46
    /**
47
     * Reverse the migrations.
48
     *
49
     * @return void
50
     */
51
    public function down()
52
    {
53
        Schema::dropIfExists($this->tablePrefix.'filters');
54
    }
55
}
56