<?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('feeding_logs', function (Blueprint $table) {
            $table->id();
            $table->foreignId('pond_id')->constrained()->cascadeOnDelete();
            $table->foreignId('cycle_id')->constrained('production_cycles')->cascadeOnDelete();
            $table->date('feed_date');
            $table->enum('feed_time', ['morning', 'afternoon', 'evening']);
            $table->string('feed_brand');
            $table->string('feed_type');
            $table->decimal('quantity_kg', 8, 2);
            $table->unsignedInteger('estimated_fish_count')->nullable();
            $table->enum('feeding_response', ['excellent', 'good', 'poor', 'refused'])->nullable();
            $table->text('notes')->nullable();
            $table->foreignId('logged_by')->constrained('users');
            $table->timestamps();

            $table->index(['pond_id', 'cycle_id']);
            $table->index(['pond_id', 'feed_date']);
        });
    }

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