<?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('equipments', function (Blueprint $table) {
            if (!Schema::hasColumn('equipments', 'min_rate')) {
                $table->decimal('min_rate', 10, 2)->after('hourly_rate')->default(0);
            }
            if (!Schema::hasColumn('equipments', 'loading_rate')) {
                $table->decimal('loading_rate', 10, 2)->after('min_rate')->default(0);
            }
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('equipments', function (Blueprint $table) {
            $table->dropColumn(['min_rate', 'loading_rate']);
        });
    }
};
