<?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('ticket_combinations', function (Blueprint $table) {
            $table->id();
            $table->foreignId('ticket_item_id')->constrained('ticket_items')->cascadeOnDelete();
            $table->unsignedInteger('combination_no')->default(0);
            $table->char('number_4d', 4);
            $table->bigInteger('bet_amount')->default(0);
            $table->bigInteger('estimated_payout')->default(0);
            $table->timestamp('created_at')->useCurrent();

            $table->index('ticket_item_id', 'idx_ticket_combinations_item');
            $table->index('number_4d', 'idx_ticket_combinations_number');
        });
    }

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