<?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', function (Blueprint $table) {
            if (!Schema::hasColumn('buku', 'lokasi_x')) {
                $table->float('lokasi_x')->nullable()->comment('Posisi X pin pada denah (persentase 0-100)');
            }
            if (!Schema::hasColumn('buku', 'lokasi_y')) {
                $table->float('lokasi_y')->nullable()->comment('Posisi Y pin pada denah (persentase 0-100)');
            }
        });
    }

    public function down(): void
    {
        Schema::table('buku', function (Blueprint $table) {
            $table->dropColumn(['lokasi_x', 'lokasi_y']);
        });
    }
};
