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

CreateSkillDeclarationsTable::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
dl 0
loc 28
rs 9.6333
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 CreateSkillDeclarationsTable extends Migration
8
{
9
    /**
10
	 * Run the migrations.
11
	 *
12
	 * @return void
13
	 */
14
	public function up()
15
	{
16
		Schema::create('skill_declarations', function(Blueprint $table)
17
		{
18
			$table->increments('id');
19
			$table->integer('skill_id')->unsigned();
20
			$table->integer('skill_status_id')->unsigned()->nullable();
21
			$table->integer('skill_level_id')->unsigned()->nullable();
22
			$table->text('description')->nullable();
23
            $table->integer('applicant_id')->unsigned();
24
			$table->timestamps();
25
		});
26
27
        Schema::create('skill_statuses', function(Blueprint $table)
28
		{
29
			$table->increments('id');
30
			$table->string('name');
31
			$table->timestamps();
32
		});
33
34
        Schema::table('skill_declarations', function(Blueprint $table)
35
		{
36
            $table->foreign('applicant_id')->references('id')->
37
                on('applicants')->onUpdate('CASCADE')->onDelete('CASCADE');
38
            $table->foreign('skill_status_id')->references('id')->
39
                on('skill_statuses')->onUpdate('CASCADE')->onDelete('NO ACTION');
40
            $table->foreign('skill_level_id')->references('id')->
41
                on('skill_levels')->onUpdate('CASCADE')->onDelete('NO ACTION');
42
		});
43
	}
44
45
46
	/**
47
	 * Reverse the migrations.
48
	 *
49
	 * @return void
50
	 */
51
	public function down()
52
	{
53
		Schema::drop('skill_declarations');
54
        Schema::dropIfExists('skill_statuses');
55
	}
56
}
57