Completed
Pull Request — dev (#297)
by Tristan
11:17
created

ReferenceFrequencyOnWorkEnvironment::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 15
rs 9.9332
c 2
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 ReferenceFrequencyOnWorkEnvironment extends Migration
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::table('work_environments', function (Blueprint $table) {
17
            $table->dropColumn('remote_allowed');
18
            $table->dropColumn('telework_allowed');
19
            $table->dropColumn('flexible_allowed');
20
21
            $table->boolean('remote_work_allowed')->nullable();
22
            $table->integer('telework_allowed_frequency_id')->unsigned();
23
            $table->integer('flexible_hours_frequency_id')->unsigned();
24
        });
25
26
        Schema::table('work_environments', function (Blueprint $table) {
27
            $table->foreign('telework_allowed_frequency_id')->references('id')->on('frequencies')->onUpdate('CASCADE')->onDelete('NO ACTION');
28
            $table->foreign('flexible_hours_frequency_id')->references('id')->on('frequencies')->onUpdate('CASCADE')->onDelete('NO ACTION');
29
        });
30
    }
31
32
    /**
33
     * Reverse the migrations.
34
     *
35
     * @return void
36
     */
37
    public function down()
38
    {
39
        Schema::table('work_environments', function (Blueprint $table) {
40
            $table->dropForeign('work_environments_telework_allowed_frequency_id_foreign');
41
            $table->dropForeign('work_environments_flexible_hours_frequency_id_foreign');
42
        });
43
44
        Schema::table('work_environments', function (Blueprint $table) {
45
            $table->dropColumn('remote_work_allowed');
46
            $table->dropColumn('telework_allowed_frequency_id');
47
            $table->dropColumn('flexible_hours_frequency_id');
48
49
            $table->string('remote_allowed')->nullable();
50
			$table->string('telework_allowed')->nullable();
51
			$table->string('flexible_allowed')->nullable();
52
        });
53
    }
54
}
55