<?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::connection('website')->create('mall_history', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedInteger('account_id');
            $table->enum('transaction_type', ['purchase', 'wheel_spin', 'small_wheel_spin', 'tombola'])->default('purchase');
            $table->unsignedInteger('item_vnum')->nullable();
            $table->unsignedInteger('item_count')->default(1);
            $table->enum('currency_type', ['cash', 'mileage'])->default('cash');
            $table->unsignedInteger('amount_spent')->default(0);
            $table->text('description')->nullable();
            $table->timestamp('created_at')->useCurrent();

            $table->index('account_id');
            $table->index('created_at');
            $table->index('transaction_type');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::connection('website')->dropIfExists('mall_history');
    }
};
