Completed
Push — feature/default-questions-for-... ( 71cb2f...4b5016 )
by Chris
14:16 queued 06:35
created

CreateAssessmentsTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 12
c 2
b 0
f 0
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 3 1
A up() 0 14 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')->on('screening_plans')->onUpdate('CASCADE')->onDelete('CASCADE');
26
            $table->foreign('criterion_id')->references('id')->on('criteria')->onUpdate('CASCADE')->onDelete('NO ACTION');
27
            $table->foreign('assessment_type_id')->references('id')->on('assessment_types')->onUpdate('CASCADE')->onDelete('NO ACTION');
28
        });
29
    }
30
31
    /**
32
     * Reverse the migrations.
33
     *
34
     * @return void
35
     */
36
    public function down()
37
    {
38
        Schema::dropIfExists('assessments');
39
    }
40
}
41