<?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('resume_reports', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->unique()->constrained()->cascadeOnDelete();
            $table->string('original_filename');
            $table->string('disk')->default('local');
            $table->string('path');
            $table->string('mime_type', 120);
            $table->unsignedInteger('size_bytes');
            $table->string('status', 50)->default('pending')->index();
            $table->unsignedTinyInteger('ats_score')->nullable()->index();
            $table->unsignedTinyInteger('remote_readiness_score')->nullable()->index();
            $table->json('extracted_skills')->nullable();
            $table->json('role_suggestions')->nullable();
            $table->json('missing_keywords')->nullable();
            $table->json('resume_improvements')->nullable();
            $table->json('analysis')->nullable();
            $table->text('failure_reason')->nullable();
            $table->timestamp('analyzed_at')->nullable()->index();
            $table->timestamps();
        });
    }

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