<?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
    {
        // Create log tables for all existing warehouses
        \App\Services\WarehouseLogService::createLogTablesForAllWarehouses();
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        // Optionally drop all warehouse log tables
        // This is commented out to preserve logs even if migration is rolled back
        // $warehouses = \App\Models\Warehouse::all();
        // foreach ($warehouses as $warehouse) {
        //     $tableName = \App\Services\WarehouseLogService::getLogTableName($warehouse->id);
        //     if (Schema::hasTable($tableName)) {
        //         Schema::dropIfExists($tableName);
        //     }
        // }
    }
};
