<?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::create('project_month_plans', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->uuid('project_id');
            $table->date('month'); // First day of month
            $table->decimal('planned_hours', 10, 2)->nullable(); // null = blank/unset
            $table->timestamps();

            // Unique constraint: one plan per project per month
            $table->unique(['project_id', 'month']);

            // Foreign key
            $table->foreign('project_id')
                ->references('id')
                ->on('projects')
                ->onDelete('cascade');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('project_month_plans');
    }
};
