<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('cube', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('pid');
            $table->dateTime('time')->useCurrent();
            $table->unsignedInteger('x');
            $table->unsignedInteger('y');
            // Can't reference due to item_proto being reloaded
            $table->unsignedInteger('item_vnum')->index('item_vnum');
            $table->unsignedInteger('item_uid')->index('item_uid');
            $table->unsignedInteger('item_count');
            $table->boolean('success')->default(false);

            $table->foreign('pid')->references('id')->on('player');
        });
    }

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