<?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()
    {
        // TODO Check if this is useless, doesn't seem to be getting used at all
        Schema::create('loginlog', function (Blueprint $table) {
            $table->unsignedInteger('id', true)->primary();
            $table->text('type')->nullable();
            $table->boolean('is_gm')->default(false);
            $table->dateTime('login_time')->nullable();
            $table->integer('channel')->nullable();
            $table->unsignedInteger('account_id')->nullable();
            $table->unsignedInteger('pid')->nullable();
            $table->text('client_version')->nullable();
            $table->text('ip')->nullable();
            $table->dateTime('logout_time')->nullable();
            $table->integer('playtime')->default(0);

            $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('loginlog2');
    }
};
