Passed
Push — dependabot/npm_and_yarn/string... ( b56eb5...bc569b )
by
unknown
45:46 queued 33s
created

CreateModulesTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 2
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class CreateModulesTable extends Migration
8
{
9
    public function up()
10
    {
11
        Schema::create('modules', function (Blueprint $table) {
12
            $table->increments('id');
13
            $table->unsignedInteger('page_id')->nullable();
14
            $table->string('collection', 32)->index();
15
            $table->string('slug');
16
            $table->timestamps();
17
            $table->softDeletes();
18
19
            $table->foreign('page_id')->references('id')->on('pages')->onDelete('cascade');
20
        });
21
22
        Schema::create('module_translations', function (Blueprint $table) {
23
            $table->increments('id');
24
            $table->integer('module_id')->unsigned();
25
            $table->string('locale');
26
            $table->string('title')->nullable();
27
            $table->text('content')->nullable();
28
            $table->timestamps();
29
30
            $table->foreign('module_id')->references('id')->on('modules')->onDelete('cascade');
31
        });
32
    }
33
34
    public function down()
35
    {
36
        Schema::dropIfExists('module_translations');
37
        Schema::dropIfExists('modules');
38
    }
39
}
40