Completed
Push — master ( 0c75f6...35d3bb )
by Stéphane
14:38
created

AddBaseFields::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 9.4285
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
6
class AddBaseFields extends Migration
7
{
8 222
    public function fieldTableFields(Blueprint $table)
9
    {
10 222
        $table->increments('id');
11 222
        $table->string('name');
12 222
        $table->integer('weight');
13
14 222
        $table->timestamps();
15
16 222
        $table->unsignedInteger('revision_id');
17 222
        $table->foreign('revision_id')->references('id')->on('revisions');
18 222
    }
19
20
    /**
21
     * Run the migrations.
22
     *
23
     * @return void
24
     */
25 222
    public function up()
26
    {
27 222
        Schema::create(
28 222
            'field_integer',
29
            function (Blueprint $table) {
30 222
                $this->fieldTableFields($table);
31 222
                $table->integer('value');
32 222
            }
33 222
        );
34
35 222
        Schema::create(
36 222
            'field_double',
37
            function (Blueprint $table) {
38 222
                $this->fieldTableFields($table);
39 222
                $table->double('value');
40 222
            }
41 222
        );
42
43 222
        Schema::create(
44 222
            'field_boolean',
45 222
            function (Blueprint $table) {
46 222
                $this->fieldTableFields($table);
47 222
                $table->boolean('value');
48 222
            }
49 222
        );
50 222
    }
51
52
    /**
53
     * Reverse the migrations.
54
     *
55
     * @return void
56
     */
57 222
    public function down()
58
    {
59 222
        Schema::drop('field_integer');
60 222
        Schema::drop('field_double');
61 222
        Schema::drop('field_boolean');
62 222
    }
63
}
64