<?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::table('inventory_sync_runs', function (Blueprint $table) {
            $table
                ->foreignId('operation_run_id')
                ->nullable()
                ->constrained('operation_runs')
                ->nullOnDelete()
                ->index();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('inventory_sync_runs', function (Blueprint $table) {
            $table->dropForeign(['operation_run_id']);
            $table->dropColumn('operation_run_id');
        });
    }
};
