<?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::table('accounts', function (Blueprint $table) {
            // Tambahkan branch_id, nullable karena bisa bernilai 'all' (global) dari frontend
            $table->unsignedBigInteger('branch_id')->nullable()->after('id');
            
            // Opsional tapi sangat disarankan: buat foreign key untuk integritas data
            // $table->foreign('branch_id')->references('id')->on('branches')->onDelete('restrict');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('accounts', function (Blueprint $table) {
            // $table->dropForeign(['branch_id']); // Buka komentar jika menggunakan foreign key
            $table->dropColumn('branch_id');
        });
    }
};