<?php

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

return new class extends Migration
{
    /**
     * Tambahkan kolom untuk filter lanjutan.
     */
    public function up(): void
    {
        Schema::table('koleksis', function (Blueprint $table) {
            if (!Schema::hasColumn('koleksis', 'tipe')) {
                $table->string('tipe')->nullable()->after('nomor_eksemplar');
            }
            if (!Schema::hasColumn('koleksis', 'bahasa')) {
                $table->string('bahasa')->nullable()->after('tipe');
            }
            if (!Schema::hasColumn('koleksis', 'subjek')) {
                $table->string('subjek')->nullable()->after('bahasa');
            }
        });
    }

    /**
     * Hapus kolom jika di-rollback.
     */
    public function down(): void
    {
        Schema::table('koleksis', function (Blueprint $table) {
            $table->dropColumn(['tipe', 'bahasa', 'subjek']);
        });
    }
};

