<?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::create('actuals', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->foreignUuid('project_id')->constrained('projects');
            $table->foreignUuid('team_member_id')->constrained('team_members');
            $table->date('month'); // First day of the month
            $table->decimal('hours_logged', 8, 2)->default(0);
            $table->timestamps();

            // Composite indexes for common queries
            $table->index(['project_id', 'month'], 'idx_actuals_project_month');
            $table->index(['team_member_id', 'month'], 'idx_actuals_member_month');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('actuals');
    }
};
