<?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::connection('player')->create('shop', function (Blueprint $table) {
            $table->integer('vnum')->default(0)->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::connection('player')->dropIfExists('shop');
    }
};
