<?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('player_index', function (Blueprint $table) {
            $table->unsignedInteger('id');
            $table->unsignedInteger('pid1')->nullable();
            $table->unsignedInteger('pid2')->nullable();
            $table->unsignedInteger('pid3')->nullable();
            $table->unsignedInteger('pid4')->nullable();
            $table->tinyInteger('empire')->default(0);

            $table->foreign('id')->references('id')->on('account');
            $table->foreign('pid1')->references('id')->on('player');
            $table->foreign('pid2')->references('id')->on('player');
            $table->foreign('pid3')->references('id')->on('player');
            $table->foreign('pid4')->references('id')->on('player');
        });
    }

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