<?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('daily_logs', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
            $table->foreignId('tank_id')->constrained('tanks')->cascadeOnDelete();
            $table->foreignId('batch_id')->nullable()->constrained('batches')->nullOnDelete();
            $table->date('date');
            $table->unsignedInteger('deaths')->default(0);
            $table->unsignedInteger('feed_given_g')->default(0);
            $table->unsignedInteger('feed_not_delivered_g')->default(0);
            $table->decimal('ph', 5, 2)->nullable();
            $table->decimal('nitrite', 8, 3)->nullable();
            $table->decimal('nitrate', 8, 3)->nullable();
            $table->decimal('ammonia', 8, 3)->nullable();
            $table->decimal('dissolved_oxygen', 8, 3)->nullable();
            $table->decimal('temp_c', 5, 2)->nullable();
            $table->decimal('alkalinity_kh', 8, 3)->nullable();
            $table->decimal('turbidity', 8, 3)->nullable();
            $table->decimal('conductivity', 10, 3)->nullable();
            $table->decimal('orp', 10, 3)->nullable();
            $table->text('floccules_notes')->nullable();
            $table->text('notes')->nullable();
            $table->timestamps();
        });
    }

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