<?php

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

class CreateQAUserAnswerSelectedTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('qa_user_answer_selected', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id')->default(0);
            $table->unsignedBigInteger('source_id')->default(0);
            $table->unsignedBigInteger('question_id');
            $table->unsignedBigInteger('answer_option_id')->default(0);
            $table->string('free_text_answer')->nullable();
            $table->string('reference')->nullable();
            $table->timestamps();
            $table->softDeletes();

            $table->foreign('question_id')->references('id')->on('qa_questions');
            // $table->foreign('answer_option_id')->references('id')->on('qa_answer_options');
            // $table->foreign('user_id')->references('id')->on('users');
            // $table->foreign('source_id')->references('id')->on('qa_user_source');
        });
    }

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