Completed
Push — master ( f606cd...f6df63 )
by
unknown
03:49 queued 02:25
created

CreateForeignKey   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 71
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
B up() 0 39 1
A down() 0 18 1
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class CreateForeignKey extends Migration
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::table('transition_states', function(Blueprint $table){
17
            $table->foreign('history_id')
18
            ->references('id')
19
            ->on('histories')
20
            ->onDelete('set null')
21
            ->onUpdate('restrict');
22
        });
23
        Schema::table('histories', function(Blueprint $table){
24
            $table->foreign('workflow_id')
25
            ->references('id')
26
            ->on('workflows')
27
            ->onDelete('set null')
28
            ->onUpdate('restrict');
29
        });
30
        Schema::table('histories', function(Blueprint $table){
31
            $table->foreign('workflow_transition_id')
32
            ->references('id')
33
            ->on('workflow_transition')
34
            ->onDelete('set null')
35
            ->onUpdate('restrict');
36
        });
37
        Schema::table('workflow_transition', function(Blueprint $table){
38
            $table->foreign('workflow_id')
39
            ->references('id')
40
            ->on('workflows')
41
            ->onDelete('set null')
42
            ->onUpdate('restrict');
43
        });
44
        Schema::table('workflow_state', function(Blueprint $table){
45
            $table->foreign('workflow_id')
46
            ->references('id')
47
            ->on('workflows')
48
            ->onDelete('set null')
49
            ->onUpdate('restrict');
50
        });
51
        
52
    }
53
54
    /**
55
     * Reverse the migrations.
56
     *
57
     * @return void
58
     */
59
    public function down()
60
    {
61
        Schema::table('transition_states', function(Blueprint $table) {
62
            $table->dropForeign('transition_states_history_id_foreign');         
63
        });
64
        Schema::table('histories', function(Blueprint $table) {
65
            $table->dropForeign('histories_workflow_id_foreign');
66
        });
67
        Schema::table('histories', function(Blueprint $table) {
68
            $table->dropForeign('histories_workflow_transition_id_foreign');
69
        });
70
        Schema::table('workflow_state', function(Blueprint $table) {
71
            $table->dropForeign('workflow_state_workflow_id_foreign');
72
        });
73
        Schema::table('workflow_transition', function(Blueprint $table) {
74
            $table->dropForeign('workflow_transition_workflow_id_foreign');
75
        });
76
    }
77
}
78