<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('fixed_asset_allocations', function (Blueprint $table) {
            $table->enum('destination_type', ['project', 'repair_shop', 'warehouse'])
                  ->default('project')
                  ->after('allocation_date');

            // Make project_id nullable so repair_shop / warehouse allocations don't require a project
            $table->unsignedBigInteger('project_id')->nullable()->change();
        });
    }

    public function down(): void
    {
        Schema::table('fixed_asset_allocations', function (Blueprint $table) {
            $table->dropColumn('destination_type');
            $table->unsignedBigInteger('project_id')->nullable(false)->change();
        });
    }
};
