<?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('processed_overtimes', function (Blueprint $table) {
            if (!Schema::hasColumn('processed_overtimes', 'meal_amount')) {
                $table->float('meal_amount',8,2)->after('meal');
            }
            
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('processed_overtimes', function (Blueprint $table){
            $columns = [
                'meal_amount',
            ];

            foreach ($columns as $column) {
                if (Schema::hasColumn('processed_overtimes', $column)) {
                    $table->dropColumn($column);
                }
            }unset($column);
        });
    }
};
