<?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
    {
        Schema::create('legacy_import_maps', function (Blueprint $table) {
            $table->id();
            $table->string('source_system', 100);
            $table->string('source_table', 100);
            $table->string('source_id', 100);
            $table->string('target_table', 100);
            $table->unsignedBigInteger('target_id');
            $table->json('meta')->nullable();
            $table->timestamps();

            $table->unique(['source_system', 'source_table', 'source_id', 'target_table'], 'legacy_import_maps_unique');
            $table->index(['target_table', 'target_id'], 'legacy_import_maps_target_index');
        });
    }

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