<?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('daily_work_logs', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained()->cascadeOnDelete();
            $table->date('work_date');
            $table->unsignedInteger('total_tracked_seconds')->default(0);
            $table->unsignedInteger('total_idle_seconds')->default(0);
            $table->unsignedInteger('productive_seconds')->default(0);
            $table->decimal('productivity_score', 5, 2)->default(0);
            $table->unsignedInteger('estimated_seconds')->default(0);
            $table->unsignedInteger('actual_seconds')->default(0);
            $table->text('notes')->nullable();
            $table->timestamps();
            $table->softDeletes();
            $table->unique(['user_id', 'work_date']);
        });
    }

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