<?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', function (Blueprint $table) {
            $table->id('DatasetId');
            $table->integer('instansi_id');
            $table->integer('template_id');
            $table->integer('template_default');
            $table->string('name');
            $table->integer('publik');
            $table->json('tags')->nullable();
            $table->json('data')->nullable();
            $table->string('file')->nullable();
            $table->json('topik')->nullable();
            $table->text('deskripsi')->nullable();
            $table->year('tahun')->nullable();
            $table->integer('status')->default(1);
            $table->integer('created_by');
            $table->timestampsTz();

            $table->foreign('instansi_id')->references('MsInstansiId')->on('ms_instansi')->cascadeOnDelete();
            $table->foreign('created_by')->references('id')->on('users')->cascadeOnDelete();
        });
    }

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