<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('job_applications', function (Blueprint $table) {
            $table->id();
            $table->foreignId('job_posting_id')->constrained('job_postings')->cascadeOnDelete();
            $table->string('full_name');
            $table->string('email');
            $table->string('phone');
            $table->text('cover_letter')->nullable();
            $table->string('cv_path');
            $table->string('cv_original_name');
            $table->string('linkedin_url')->nullable();
            $table->enum('status', ['yeni', 'incelendi', 'görüşmeye_çağrıldı', 'reddedildi', 'işe_alındı'])->default('yeni');
            $table->text('internal_notes')->nullable();
            $table->string('source')->nullable();
            $table->boolean('kvkk_consent')->default(false);
            $table->timestamp('kvkk_consent_at')->nullable();
            $table->foreignId('reviewed_by')->nullable()->constrained('users')->nullOnDelete();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('job_applications');
    }
};