<?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('t_excel_upload_logs', function (Blueprint $table) {
            $table->id();
            $table->string('upload_type', 50); // 'holidays', 'item_conversions', 'menus', etc.
            $table->string('uploaded_file', 255);
            $table->string('original_filename', 255);
            $table->integer('total_rows')->default(0);
            $table->integer('success_rows')->default(0);
            $table->integer('error_rows')->default(0);
            $table->text('error_details')->nullable();
            $table->enum('status', ['Success', 'Partial', 'Failed'])->default('Success');
            $table->unsignedBigInteger('uploaded_by');
            $table->timestamps();

            $table->foreign('uploaded_by')->references('id')->on('users');
            $table->index(['upload_type', 'created_at']);
        });
    }

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