<?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('player_wallets', function (Blueprint $table) {
            $table->id();
            $table->foreignId('player_id')->constrained('players')->cascadeOnDelete();
            $table->string('wallet_type', 32)->default('lottery');
            $table->string('currency_code', 16);
            $table->bigInteger('balance')->default(0);
            $table->bigInteger('frozen_balance')->default(0);
            $table->unsignedTinyInteger('status')->default(0)->comment('0=active,1=frozen');
            $table->unsignedBigInteger('version')->default(0);
            $table->timestamps();

            $table->unique(['player_id', 'wallet_type', 'currency_code'], 'uk_player_wallets_player_type_currency');
        });
    }

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