Completed
Pull Request — dev (#317)
by Tristan
06:21
created

ModifyReferencesTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 11 1
A up() 0 10 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 ModifyReferencesTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::table('micro_references', function (Blueprint $table) {
17
            $table->dropForeign(['experience_level_id']);
18
            $table->dropIndex(['experience_level_id']);
19
20
            $table->dropColumn('experience_level_id');
21
            $table->dropColumn('observed_from_date');
22
            $table->dropColumn('observed_until_date');
23
            $table->renameColumn('story', 'description');
24
        });
25
    }
26
27
    /**
28
     * Reverse the migrations.
29
     *
30
     * @return void
31
     */
32
    public function down()
33
    {
34
        Schema::table('micro_references', function (Blueprint $table) {
35
            $table->integer('experience_level_id')->unsigned()->nullable()->index();
36
            $table->date('observed_from_date')->nullable();
37
			$table->date('observed_until_date')->nullable();
38
            $table->renameColumn('description', 'story');
39
        });
40
41
        Schema::table('micro_references', function (Blueprint $table) {
42
            $table->foreign('experience_level_id')->references('id')->on('experience_levels')->onUpdate('CASCADE')->onDelete('NO ACTION');
43
        });
44
    }
45
}
46