<?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::create('work_order_merges', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('merged_work_order_id');
            $table->json('source_work_order_ids');
            $table->timestamps();

            $table->foreign('merged_work_order_id')
                ->references('id')
                ->on('work_order_masters')
                ->onDelete('cascade');
        });
    }

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