<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('questionnaire_responses', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->unique()->constrained()->cascadeOnDelete();
            $table->json('answers');
            $table->json('preferred_categories')->nullable();
            $table->json('preferred_roles')->nullable();
            $table->json('skills')->nullable();
            $table->string('experience_level', 50)->nullable()->index();
            $table->string('availability', 50)->nullable()->index();
            $table->string('preferred_timezone', 80)->nullable()->index();
            $table->string('country_code', 2)->nullable()->index();
            $table->string('salary_currency', 3)->default('USD')->index();
            $table->unsignedInteger('salary_min')->nullable()->index();
            $table->boolean('open_to_contract')->default(false)->index();
            $table->boolean('open_to_full_time')->default(false)->index();
            $table->timestamp('completed_at')->nullable()->index();
            $table->timestamps();
        });
    }

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