<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('players', function (Blueprint $table) {
            $table->id();
            $table->string('site_code', 64);
            $table->string('site_player_id', 128);
            $table->string('username', 128)->nullable();
            $table->string('nickname', 128)->nullable();
            $table->string('default_currency', 16)->default('NPR');
            $table->unsignedTinyInteger('status')->default(0)->comment('0=active,1=frozen,2=blocked');
            $table->timestamp('last_login_at')->nullable();
            $table->timestamps();

            $table->unique(['site_code', 'site_player_id'], 'uk_players_site_player');
            $table->index('status', 'idx_players_status');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('players');
    }
};
