Passed
Pull Request — dev (#313)
by Tristan
06:51
created

MakeDegreeTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 4 1
A up() 0 25 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 MakeDegreeTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('degrees', function (Blueprint $table) {
17
            $table->increments('id');
18
            $table->integer('degree_type_id')->unsigned()->nullable();
19
            $table->string('area_of_study')->nullable();
20
            $table->string('institution')->nullable();
21
            $table->string('thesis')->nullable();
22
            $table->date('start_date')->nullable();
23
            $table->date('end_date')->nullable();
24
            $table->integer('applicant_id')->unsigned();
25
            $table->timestamps();
26
        });
27
28
         Schema::create('degree_types', function (Blueprint $table) {
29
            $table->increments('id');
30
            $table->string('name');
31
            $table->timestamps();
32
        });
33
34
        Schema::table('degrees', function (Blueprint $table) {
35
            $table->foreign('degree_type_id')->references('id')->
36
                on('degree_types')->onUpdate('CASCADE')->onDelete('NO ACTION');
37
            $table->foreign('applicant_id')->references('id')->
38
                on('applicants')->onUpdate('CASCADE')->onDelete('CASCADE');
39
        });
40
    }
41
42
    /**
43
     * Reverse the migrations.
44
     *
45
     * @return void
46
     */
47
    public function down()
48
    {
49
        Schema::dropIfExists('degrees');
50
        Schema::dropIfExists('degree_types');
51
    }
52
}
53