<?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('user_instansi', function (Blueprint $table) {
            $table->id('UserInstansiId');
            $table->integer('user_id');
            $table->integer('ms_instansi_id');
            $table->timestampsTz();

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

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