<?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('tx_dataset', function (Blueprint $table) {
            $table->id('TxDatasetId');
            $table->integer('dataset_id');
            $table->integer('ms_tabel_data_id');
            $table->integer('ms_tabel_data_kolom_id');
            $table->text('value')->nullable();
            $table->timestampsTz();

            $table->foreign('dataset_id')->references('DatasetId')->on('dataset')->cascadeOnDelete();
            $table->foreign('ms_tabel_data_id')->references('MsTabelDataId')->on('ms_tabel_data')->cascadeOnDelete();
            $table->foreign('ms_tabel_data_kolom_id')->references('MsTabelDataKolomId')->on('ms_tabel_data_kolom')->cascadeOnDelete();
        });
    }

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