<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('import_logs', function (Blueprint $table) {
            $table->id();
            $table->morphs('importable');
            $table->string('type')->nullable();
            $table->string('file_path')->nullable();
            $table->string('status')->nullable();
            $table->string('progress')->nullable()->default(0);

            $table->timestamps();
            $table->softDeletes();

            $table->foreignId('created_by')->nullable()->index();
            $table->foreignId('updated_by')->nullable()->index();
            $table->foreignId('deleted_by')->nullable()->index();

            $table->index(['importable_id', 'importable_type']);
            $table->index(['importable_id', 'importable_type', 'type']);
        });
    }

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