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

MakeCourseTable::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class MakeCourseTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('courses', function (Blueprint $table) {
17
            $table->increments('id');
18
            $table->string('name')->nullable();
19
            $table->string('institution')->nullable();
20
            $table->integer('course_status_id')->unsigned()->nullable();
21
            $table->date('start_date')->nullable();
22
            $table->date('end_date')->nullable();
23
            $table->integer('applicant_id')->unsigned();
24
            $table->timestamps();
25
        });
26
27
        Schema::create('course_status', function (Blueprint $table) {
28
           $table->increments('id');
29
           $table->string('name');
30
           $table->timestamps();
31
        });
32
33
        Schema::table('courses', function (Blueprint $table) {
34
            $table->foreign('course_status_id')->references('id')->
35
                on('course_status')->onUpdate('CASCADE')->onDelete('NO ACTION');
36
            $table->foreign('applicant_id')->references('id')->
37
                on('applicants')->onUpdate('CASCADE')->onDelete('CASCADE');
38
        });
39
    }
40
41
    /**
42
     * Reverse the migrations.
43
     *
44
     * @return void
45
     */
46
    public function down()
47
    {
48
        Schema::dropIfExists('courses');
49
        Schema::dropIfExists('course_status');
50
    }
51
}
52