<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shop', function (Blueprint $table) {
            $table->unsignedInteger('vnum')->primary();
            $table->string('name', 32)->default('Noname');
            $table->smallInteger('npc_vnum')->default(0);
        });

        // Populate the table data
        $data = File::json(database_path('data/shop.json'));
        \App\Models\Game\Player\Shop::upsert($data, ['vnum']);
    }

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