<?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('dataset_table29', function (Blueprint $table) {
            $table->id('DatasetTable29Id');
            $table->integer('dataset_id');
            $table->string('nama_sungai')->nullable();       // Nama Sungai
            $table->string('lokasi')->nullable();            // Lokasi
            $table->string('titik_pantau')->nullable();      // Titik Pantau
            $table->float('koordinat_lintang')->default(0);  // Koordinat Lintang
            $table->float('koordinat_bujur')->default(0);    // Koordinat Bujur
            $table->date('waktu_sampling')->nullable();      // Waktu Sampling (tgl/bln/thn)
            $table->float('temperatur')->default(0);         // Temperatur (ºC)
            $table->float('ph')->default(0);                 // pH
            $table->float('dhl')->default(0);                // DHL (µS/cm)
            $table->float('tds')->default(0);                // TDS (mg/L)
            $table->float('tss')->default(0);                // TSS (mg/L)
            $table->float('do')->default(0);                 // DO (mg/L)
            $table->float('bod')->default(0);                // BOD (mg/L)
            $table->float('cod')->default(0);                // COD (mg/L)
            $table->float('no2')->default(0);                // NO2 (mg/L)
            $table->float('no3')->default(0);                // NO3 (mg/L)
            $table->float('nh3')->default(0);                // NH3 (mg/L)
            $table->float('klorin_bebas')->default(0);       // Klorin Bebas (mg/L)
            $table->float('tp')->default(0);                 // T-P (mg/L)
            $table->float('fenol')->default(0);              // Fenol (µg/L)
            $table->float('minyak_lemak')->default(0);       // Minyak dan Lemak (µg/L)
            $table->float('detergen')->default(0);           // Detergen (µg/L)
            $table->float('fecal_coliform')->default(0);     // Fecal coliform (jmlh)
            $table->float('total_coliform')->default(0);     // Total coliform (jmlh/100ml)
            $table->float('sianida')->default(0);            // Sianida (mg/L)
            $table->float('h2s')->default(0);                // H2S (mg/L)
            $table->integer('created_by');
            $table->timestampsTz();
            $table->softdeletesTz();

            $table->foreign('dataset_id')->references('DatasetId')->on('dataset')->cascadeOnDelete();
        });
    }

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