<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('player_rankings', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('role_id')->unique();
            $table->string('role_name');
            $table->unsignedTinyInteger('cls')->default(0);
            $table->unsignedInteger('level')->default(0);
            $table->unsignedBigInteger('reputation')->default(0);
            $table->string('faction_name')->nullable();
            $table->timestamp('last_update')->nullable();
            $table->timestamps();
            
            $table->index(['reputation', 'level']);
            $table->index('role_name');
        });
    }

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