<?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
    {
        if (Schema::hasTable('tbl_universal_pedido_imports')) {
            return;
        }

        Schema::create('tbl_universal_pedido_imports', function (Blueprint $table) {
            $table->increments('id_universal_pedido_import');

            $table->unsignedInteger('universal_pedido_id')->unique();
            $table->string('order_reference', 9)->nullable()->unique();

            $table->dateTime('universal_updated_at')->nullable();
            $table->dateTime('imported_at')->nullable();

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

    public function down(): void
    {
        // Intencionalmente no hacemos drop para evitar pérdida de tracking.
    }
};
