<?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('import_records', function (Blueprint $t) { $t->id(); $t->unsignedBigInteger('batch_id'); $t->string('external_ref', 191); $t->string('entity', 32); $t->string('status', 20); $t->string('target_type', 191)->nullable(); $t->unsignedBigInteger('target_id')->nullable(); $t->string('message', 255)->nullable(); $t->timestamp('created_at')->nullable(); $t->timestamp('updated_at')->nullable(); $t->index('batch_id', 'import_records_batch_id_foreign'); $t->index(['entity', 'external_ref'], 'import_records_entity_external_ref_index'); $t->index(['target_type', 'target_id'], 'import_records_target_type_target_id_index'); $t->foreign('batch_id', 'import_records_batch_id_foreign')->references('id')->on('import_batches')->onDelete('cascade'); }); } public function down(): void { Schema::dropIfExists('import_records'); } }; 