<?php

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

class AddDivisiIdToKegiatansTable extends Migration
{
    public function up()
    {
        Schema::table('kegiatans', function (Blueprint $table) {
            $table->unsignedBigInteger('divisi_id')->nullable()->after('instansi_id');
            $table->foreign('divisi_id')->references('id')->on('divisis')->onDelete('set null');
        });
    }

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