<?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('species_configs', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('farm_id')->default(1);
            $table->string('name');
            $table->decimal('target_weight_g', 8, 2)->default(1000);
            $table->decimal('safe_ph_min', 4, 2)->default(6.5);
            $table->decimal('safe_ph_max', 4, 2)->default(8.5);
            $table->decimal('warning_ph_min', 4, 2)->default(6.0);
            $table->decimal('warning_ph_max', 4, 2)->default(9.0);
            $table->decimal('safe_do_min_mgl', 5, 2)->default(4.0);
            $table->decimal('warning_do_min_mgl', 5, 2)->default(2.0);
            $table->decimal('safe_temp_min_c', 4, 1)->default(25.0);
            $table->decimal('safe_temp_max_c', 4, 1)->default(30.0);
            $table->decimal('safe_ammonia_max_ppm', 6, 4)->default(0.05);
            $table->decimal('safe_nitrite_max_ppm', 6, 4)->default(0.1);
            $table->boolean('is_active')->default(true);
            $table->timestamps();

            $table->index('farm_id');
        });
    }

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