CreatePostsTable::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class CreatePostsTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('posts', function (Blueprint $table) {
17
            $table->increments('id');
18
            $table->integer('category_id')->unsigned();
19
            $table->string('title');
20
            $table->string('slug');
21
            $table->text('body');
22
            $table->dateTime('published_at');
23
            $table->boolean('visible')->default(true);
24
            $table->boolean('featured')->default(false);
25
            $table->timestamps();
26
27
            $table->foreign('category_id')->references('id')->on('categories');
28
29
            $table->index('slug');
30
        });
31
    }
32
33
    /**
34
     * Reverse the migrations.
35
     *
36
     * @return void
37
     */
38
    public function down()
39
    {
40
        Schema::dropIfExists('posts');
41
    }
42
}
43