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

CreateNoteTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 2
1
<?php
2
3
use Illuminate\Database\Schema\Blueprint;
4
use Illuminate\Database\Migrations\Migration;
5
6
class CreateNoteTable extends Migration
7
{
8
    public function up()
9
    {
10
        Schema::create('notes', function (Blueprint $table) {
11
            $table->increments('id');
12
            $table->boolean('published')->default(0);
13
            $table->enum('type', ['general', 'delivery', 'payment']);
14
            $table->boolean('cookies');
15
            $table->enum('level', ['info', 'warning', 'error']);
16
            $table->timestamp('start_at')->nullable();
17
            $table->timestamp('end_at')->nullable();
18
            $table->timestamps();
19
        });
20
21
        Schema::create('note_translations', function (Blueprint $table) {
22
            $table->increments('id');
23
            $table->integer('note_id')->unsigned();
24
            $table->string('locale');
25
            $table->string('content');
26
27
            $table->unique(['note_id', 'locale']);
28
            $table->foreign('note_id')->references('id')->on('notes')->onDelete('cascade');
29
        });
30
    }
31
32
    public function down()
33
    {
34
        Schema::dropIfExists('note_translations');
35
        Schema::dropIfExists('notes');
36
    }
37
}
38