<?php

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

/**
 * PRC-1143 — konsolide şema: `ticket_original_emails` tablosunun TAM tanımı (tek dosya).
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::create('ticket_original_emails', function (Blueprint $t) {
            $t->id();
            $t->unsignedInteger('ticket_id');
            $t->unsignedBigInteger('reply_id')->nullable();
            $t->string('file_path', 512);
            $t->string('uuid', 64);
            $t->string('from_email', 255)->nullable();
            $t->string('subject', 500)->nullable();
            $t->unsignedBigInteger('file_size')->default(0);
            $t->string('scan_status', 32)->nullable();
            $t->string('date_folder', 10);
            $t->boolean('pruned')->default(0);
            $t->timestamp('pruned_at')->nullable();
            $t->timestamp('created_at')->nullable();
            $t->timestamp('updated_at')->nullable();
            $t->index('date_folder', 'ticket_original_emails_date_folder_index');
            $t->index('pruned', 'ticket_original_emails_pruned_index');
            $t->index('ticket_id', 'ticket_original_emails_ticket_id_index');
        });
    }

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