Completed
Pull Request — master (#372)
by Mike
31:01 queued 16:07
created

CreateBooks::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 9.52
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
use Illuminate\Database\Schema\Blueprint;
4
use Illuminate\Database\Migrations\Migration;
5
6
class CreateBooks extends Migration
7
{
8
    public function up()
9
    {
10
        Schema::create('books', function (Blueprint $table) {
11
            $table->increments('id');
12
            $table->unsignedInteger('author_id');
13
            $table->unsignedInteger('publisher_id');
14
            $table->timestamps();
15
16
            $table->text('description')->nullable();
17
            $table->dateTime('published_at');
18
            $table->string('title');
19
            $table->decimal('price')->default(0);
20
21
            $table->foreign('author_id')
22
                ->references('id')
23
                ->on('authors')
24
                ->onUpdate('CASCADE')
25
                ->onDelete('CASCADE');
26
            $table->foreign('publisher_id')
27
                ->references('id')
28
                ->on('publishers')
29
                ->onUpdate('CASCADE')
30
                ->onDelete('CASCADE');
31
        });
32
    }
33
}
34