<?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('item_award', function (Blueprint $table) {
            $table->unsignedInteger('id', true)->primary();
            $table->unsignedInteger('pid');
            $table->string('login', 30);
            $table->unsignedInteger('vnum');
            $table->unsignedInteger('count');
            $table->dateTime('given_time')->useCurrent()->index('given_time_idx');
            $table->dateTime('taken_time')->nullable()->index('taken_time_idx');
            $table->integer('item_id')->nullable();
            $table->string('why', 128)->nullable();
            $table->integer('socket0')->default(0);
            $table->integer('socket1')->default(0);
            $table->integer('socket2')->default(0);
            $table->boolean('mall')->default(false);

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

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