<?php

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

class AddAnswerOptionIdToResponsesTable extends Migration
{
    public function up()
    {
        Schema::table('responses', function (Blueprint $table) {
            $table->foreignId('answer_option_id')->nullable()->after('question_id')->constrained()->onDelete('set null');
        });
    }

    public function down()
    {
        Schema::table('responses', function (Blueprint $table) {
            $table->dropForeign(['answer_option_id']);
            $table->dropColumn('answer_option_id');
        });
    }
}

