<?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_table37', function (Blueprint $table) {
            $table->id('DatasetTable37Id');
            $table->integer('dataset_id');
            $table->string('lokasi')->nullable();
            $table->string('lat')->nullable();
            $table->string('long')->nullable();
            $table->string('lama_pengukuran')->nullable();
            // parameter udara pakai float default 0
            $table->float('so2')->default(0);   // µg/Nm3
            $table->float('co')->default(0);    // µg/Nm3
            $table->float('no2')->default(0);   // µg/Nm3
            $table->float('o3')->default(0);    // µg/Nm3
            $table->float('hc')->default(0);    // µg/Nm3
            $table->float('pm10')->default(0);  // µg/Nm3
            $table->float('pm25')->default(0);  // µg/Nm3
            $table->float('tsp')->default(0);   // µg/Nm3
            $table->float('pb')->default(0);    // µg/Nm3
            $table->float('dustfall')->default(0); // µg/Nm3
            $table->float('total_fluorides')->default(0); // µg/Nm3
            $table->float('fluor_index')->default(0);     // µg/Nm3
            $table->float('chlorine_dioxide')->default(0); // µg/Nm3
            $table->float('sulphat_index')->default(0);    // µg/Nm3
            $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_table37s');
    }
};
