CreateMedFormFieldValTabTables::up()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 28
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
c 1
b 0
f 0
dl 0
loc 28
rs 9.552
cc 3
nc 4
nop 0
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6
7
class CreateMedFormFieldValTabTables extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        if (!Schema::hasTable('med_form_field_val_tab')) {
17
            Schema::create('med_form_field_val_tab', function (Blueprint $table) {
18
                $table->id();
19
                $table->unsignedBigInteger('form_field_id')->nullable();
20
                $table->foreign('form_field_id')
21
                    ->references('id')
22
                    ->on('med_form_fields')
23
                    ->onDelete('set null');
24
                $table->string('table_name');
25
                $table->timestamps();
26
            });
27
        }
28
29
        if (!Schema::hasTable('med_form_field_val_tab_translations')) {
30
            Schema::create('med_form_field_val_tab_translations', function (Blueprint $table) {
31
                $table->id();
32
                $table->string('value');
33
                $table->text('text')->nullable();
34
                $table->unsignedBigInteger('val_tab_id')->nullable();
35
                $table->foreign('val_tab_id')
36
                    ->references('id')
37
                    ->on('med_form_field_val_tab')
38
                    ->onDelete('set null');
39
                $table->string('locale')->nullable();
40
                $table->text('description')->nullable();
41
                $table->timestamps();
42
            });
43
        }
44
    }
45
46
    /**
47
     * Reverse the migrations.
48
     *
49
     * @return void
50
     */
51
    public function down()
52
    {
53
        Schema::dropIfExists('med_form_field_val_tab_translations');
54
        Schema::dropIfExists('med_form_field_val_tab');
55
    }
56
}