<?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
    {
        // Add duration columns to punches table
        Schema::table('punches', function (Blueprint $table) {
            $table->integer('working_minutes')->default(0)->after('status')->comment('Populated for OUT punches');
            $table->integer('break_minutes')->default(0)->after('working_minutes')->comment('Populated for IN punches (break before this IN)');
        });

        // Add break and gross minutes to attendances
        Schema::table('attendances', function (Blueprint $table) {
            $table->integer('total_break_minutes')->default(0)->after('total_working_hours');
            $table->integer('gross_minutes')->default(0)->after('total_break_minutes');
        });
    }

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

        Schema::table('attendances', function (Blueprint $table) {
            $table->dropColumn(['total_break_minutes', 'gross_minutes']);
        });
    }
};
