<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddJabatanInstansiIdToKegiatansTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
   public function up()
{
    Schema::table('kegiatans', function (Blueprint $table) {
        // Tambahkan kolom sebagai foreign key
        $table->unsignedBigInteger('jabatan_instansi_id')->nullable()->after('instansi_id');
        
        // Opsional: Tambahkan foreign key constraint
        $table->foreign('jabatan_instansi_id')->references('id')->on('jabatan_instansis')->onDelete('cascade');
    });
}

public function down()
{
    Schema::table('kegiatans', function (Blueprint $table) {
        $table->dropForeign(['jabatan_instansi_id']);
        $table->dropColumn('jabatan_instansi_id');
    });
}
}
