<?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('levellog', function (Blueprint $table) {
            $table->char('name', 24)->default('');
            $table->tinyInteger('level')->default(0);
            $table->dateTime('time')->useCurrent();
            $table->integer('playtime')->default(0);
            $table->unsignedInteger('account_id');
            $table->unsignedInteger('pid');

            $table->primary(['name', 'level']);
            $table->foreign('account_id')->references('id')->on('account');
            $table->foreign('pid')->references('id')->on('player');
        });
    }

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