Completed
Push — master ( 7e54ec...8b45a6 )
by Vojta
9s
created

CreateReviewCategoryTable::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace VojtaSvoboda\Reviews\Updates;
2
3
use October\Rain\Database\Schema\Blueprint;
4
use October\Rain\Database\Updates\Migration;
5
use Schema;
6
7
class CreateReviewCategoryTable extends Migration
8
{
9
    public function up()
10
    {
11
        Schema::create('vojtasvoboda_reviews_review_category', function($table)
12
        {
13
            $table->engine = 'InnoDB';
14
            $table->increments('id')->unsigned();
15
            $table->integer('review_id')->unsigned()->nullable()->default(null);
16
            $table->integer('category_id')->unsigned()->nullable()->default(null);
17
            $table->index(['review_id', 'category_id']);
18
            $table->foreign('review_id')->references('id')->on('vojtasvoboda_reviews_reviews')->onDelete('cascade');
19
            $table->foreign('category_id')->references('id')->on('vojtasvoboda_reviews_categories')->onDelete('cascade');
20
            $table->timestamps();
21
        });
22
    }
23
24
    public function down()
25
    {
26
        Schema::dropIfExists('vojtasvoboda_reviews_review_category');
27
    }
28
}
29