<?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::create('topspender_character_caches', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('user_id');
            $table->unsignedTinyInteger('month');
            $table->unsignedSmallInteger('year');
            $table->string('character_name', 32)->nullable();
            $table->unsignedTinyInteger('character_class')->nullable();
            $table->timestamps();

            $table->unique(['user_id', 'month', 'year'], 'topspender_character_cache_unique');
        });
    }

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