<?php

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

/**
 * PRC-1143 — konsolide şema: `import_batches` tablosunun TAM tanımı (tek dosya).
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::create('import_batches', function (Blueprint $t) {
            $t->id();
            $t->char('uuid', 36);
            $t->string('source', 32);
            $t->string('entity', 32);
            $t->string('status', 20)->default('pending');
            $t->boolean('dry_run')->default(0);
            $t->string('file_path', 512)->nullable();
            $t->string('original_filename', 255)->nullable();
            $t->json('mapping')->nullable();
            $t->json('options')->nullable();
            $t->unsignedInteger('total')->default(0);
            $t->unsignedInteger('imported')->default(0);
            $t->unsignedInteger('skipped')->default(0);
            $t->unsignedInteger('failed')->default(0);
            $t->json('report')->nullable();
            $t->unsignedBigInteger('created_by_admin_id')->nullable();
            $t->timestamp('completed_at')->nullable();
            $t->timestamp('created_at')->nullable();
            $t->timestamp('updated_at')->nullable();
            $t->index(['source', 'entity'], 'import_batches_source_entity_index');
            $t->index('status', 'import_batches_status_index');
            $t->unique('uuid', 'import_batches_uuid_unique');
        });
    }

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