<?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('left_over_note_items', function (Blueprint $table) {
            if (! Schema::hasColumn('left_over_note_items', 'sir_item_id'))
                $table->bigInteger('sir_item_id')->nullable();

            if (! Schema::hasColumn('left_over_note_items', 'sir_id'))
                $table->bigInteger('sir_id')->nullable();

            if (! Schema::hasColumn('left_over_note_items', 'sir_item_qty'))
                $table->double('sir_item_qty')->nullable();
        });

        Schema::table('left_over_notes', function (Blueprint $table) {
            $table->dropForeign(['store_issue_requisition_id']); // or use the constraint name if known
            $table->bigInteger('store_issue_requisition_id')->nullable()->change();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('left_over_note_items', function (Blueprint $table) {
            //
        });
    }
};
