<?php

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

/**
 * Options offered but not yet answered.
 *
 * They were built from the JSON response and never stored, so reloading a
 * conversation lost them: the question stayed unanswered and the buttons that
 * answered it were gone. Exactly what happened to paused approvals before they
 * were persisted, and the same fix.
 *
 * Held on the conversation rather than the campaign because a question can be
 * about something that is not a campaign yet.
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('conversation_states', function (Blueprint $table): void {
            $table->json('pending_choices')->nullable()->after('owner_id');
        });
    }

    public function down(): void
    {
        Schema::table('conversation_states', function (Blueprint $table): void {
            $table->dropColumn('pending_choices');
        });
    }
};
