<?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('attendance_records', function (Blueprint $table) {
            $table->unsignedInteger('overtime_minutes')->default(0)->after('check_out_at');
            $table->boolean('missing_checkout')->default(false)->after('overtime_minutes');

            $table->index(['tenant_id', 'attendance_date', 'missing_checkout'], 'att_tenant_date_missing_idx');
        });
    }

    public function down(): void
    {
        Schema::table('attendance_records', function (Blueprint $table) {
            $table->dropIndex('att_tenant_date_missing_idx');
            $table->dropColumn(['overtime_minutes', 'missing_checkout']);
        });
    }
};

