Passed
Push — feature/screening-plan ( 16ec65...bbccd2 )
by Tristan
13:46
created

CreateAssessmentsTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 3 1
A up() 0 17 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 CreateAssessmentsTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('assessments', function (Blueprint $table) {
17
            $table->increments('id');
18
            $table->integer('screening_plan_id');
19
            $table->integer('criterion_id');
20
            $table->integer('assessment_type_id');
21
            $table->timestamps();
22
23
            $table->unique(['screening_plan_id', 'criterion_id', 'assessment_type_id']);
24
25
            $table->foreign('screening_plan_id')->references('id')
26
                ->on('screening_plans')->onUpdate('CASCADE')->onDelete('CASCADE');
27
            $table->foreign('criterion_id')->refernces('id')->on('criteria')
28
                ->onUpdate('CASCADE')->onDelete('NO ACTION');
29
            $table->foreign('assessment_type_id')->references('id')
30
                ->on('assessment_types')->onUpdate('CASCADE')->onDelete('NO ACTION');
31
        });
32
    }
33
34
    /**
35
     * Reverse the migrations.
36
     *
37
     * @return void
38
     */
39
    public function down()
40
    {
41
        Schema::dropIfExists('assessments');
42
    }
43
}
44