<?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('inventories', function (Blueprint $table) {
            $table->string('batch_id')->nullable()->after('created_by');
            $table->string('batch_hash')->nullable()->after('batch_id');
            $table->index(['batch_id', 'created_at']);
            $table->index('batch_hash');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('inventories', function (Blueprint $table) {
            $table->dropIndex(['batch_id', 'created_at']);
            $table->dropIndex(['batch_hash']);
            $table->dropColumn(['batch_id', 'batch_hash']);
        });
    }
};
