<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('buku_tamu', function (Blueprint $table) {
            // id_user jadi nullable (tamu non-member tidak punya user)
            $table->unsignedBigInteger('id_user')->nullable()->change();

            // Kolom untuk tamu non-member
            $table->string('nama_tamu')->nullable()->after('id_user');
            $table->string('asal_instansi')->nullable()->after('nama_tamu');
        });
    }

    public function down(): void
    {
        Schema::table('buku_tamu', function (Blueprint $table) {
            $table->dropColumn(['nama_tamu', 'asal_instansi']);
            $table->unsignedBigInteger('id_user')->nullable(false)->change();
        });
    }
};
