<?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
    {
        if (Schema::hasTable('fixed_asset_maintenance') && ! Schema::hasColumn('fixed_asset_maintenance', 'deleted_at')) {
            Schema::table('fixed_asset_maintenance', function (Blueprint $table) {
                $table->softDeletes();
            });
        }

        if (Schema::hasTable('fixed_asset_disposals') && ! Schema::hasColumn('fixed_asset_disposals', 'deleted_at')) {
            Schema::table('fixed_asset_disposals', function (Blueprint $table) {
                $table->softDeletes();
            });
        }
    }

    public function down(): void
    {
        if (Schema::hasTable('fixed_asset_maintenance') && Schema::hasColumn('fixed_asset_maintenance', 'deleted_at')) {
            Schema::table('fixed_asset_maintenance', function (Blueprint $table) {
                $table->dropSoftDeletes();
            });
        }

        if (Schema::hasTable('fixed_asset_disposals') && Schema::hasColumn('fixed_asset_disposals', 'deleted_at')) {
            Schema::table('fixed_asset_disposals', function (Blueprint $table) {
                $table->dropSoftDeletes();
            });
        }
    }
};
