<?php

use App\Models\Game\Player\ShopEx;
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::create('shopex', function (Blueprint $table) {
            $table->unsignedInteger('vnum')->primary()->autoIncrement();
            $table->string('name', 32)->default('NoName');
            $table->smallInteger('npc_vnum')->index(); // This should reference mob_proto
        });

        // Populate the table data
        $data = File::json(database_path('data/shopex.json'));

        ShopEx::upsert($data, ['vnum']);
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('shopex');
    }
};
