<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateQAQuestionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('qa_questions', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('question_number');
            $table->text('question_text');
            $table->unsignedBigInteger('questionnaire_set_id');
            $table->unsignedBigInteger('next_nested_question')->nullable();
            $table->unsignedBigInteger('next_main_question')->nullable();
            $table->unsignedBigInteger('question_type');
            $table->tinyInteger('is_start');
            $table->tinyInteger('is_end');
            $table->string('end_text')->nullable();
            $table->unsignedBigInteger('order')->default(0);
            $table->timestamps();
            $table->softDeletes();

            $table->foreign('questionnaire_set_id')->references('id')->on('qa_questionnaire_sets');

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('qa_questions');
    }
}
