<?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_table26', function (Blueprint $table) {
            $table->id('DatasetTable26Id');
            $table->integer('dataset_id');
            $table->string('lokasi_pemantauan')->nullable(); // Lokasi Pemantauan
            $table->string('latitude')->nullable();  // Latitude (7 digit desimal cukup presisi)
            $table->string('longitude')->nullable(); // Longitude
            $table->timestamp('waktu_pemantauan')->nullable(); // Waktu Pemantauan
            $table->float('ph')->default(0);    // pH biasanya 0-14 (cukup 5,2)
            $table->float('dhl')->default(0);  // DHL (konduktivitas)
            $table->float('so4')->default(0);  // SO4
            $table->float('no3')->default(0);  // NO3
            $table->float('cr')->default(0);   // Cr
            $table->float('nh4')->default(0);  // NH4
            $table->float('na')->default(0);   // Na
            $table->float('ca2')->default(0);  // Ca2+
            $table->float('mg2')->default(0);  // Mg2+

            $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_table26s');
    }
};
