CreateQuizQuestionsTable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 33
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 3 1
A up() 0 15 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 CreateQuizQuestionsTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        if (Schema::hasTable('quiz_questions')) return;
17
        
18
        Schema::create('quiz_questions', function (Blueprint $table) {
19
            $table->increments('id');
20
            $table->integer('quiz_id')->unsigned()->index();
21
            $table->text('question');
22
            $table->timestamps();
23
24
            $table->foreign('quiz_id')
25
                  ->references('id')
26
                  ->on('quizzes')
27
                  ->onDelete('cascade')
28
                  ->onUpdate('cascade');
29
        });
30
    }
31
32
    /**
33
     * Reverse the migrations.
34
     *
35
     * @return void
36
     */
37
    public function down()
38
    {
39
        Schema::dropIfExists('quiz_questions');
40
    }
41
}
42