<?php

use App\Enums\WithdrawStatusEnum;
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('withdraws', function (Blueprint $table) {
            $table->id();
            $table->foreignIdFor(\App\Models\User::class)->constrained()->cascadeOnDelete();
            $table->foreignIdFor(\App\Models\WithdrawMethod::class)->constrained()->cascadeOnDelete();
            $table->string(('track'))->unique();
            $table->string('currency', 10)->default('USD');
            $table->float('amount');
            $table->unsignedBigInteger('coins')->default(0);
            $table->float('charge')->default(0);
            $table->longText('fields')->nullable()->comment('json encoded fields and options array');
            $table->enum('status', WithdrawStatusEnum::values())->default(WithdrawStatusEnum::PENDING->value);
            $table->timestamps();
        });
    }

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