<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('roster_result_uploads', function (Blueprint $table) {
            $table->id();
            $table->string('team', 32);
            $table->date('roster_date');
            $table->foreignId('uploaded_by_user_id')->nullable()->constrained('users')->nullOnDelete();
            $table->string('source_filename');
            $table->unsignedInteger('imported_rows')->default(0);
            $table->timestamp('matched_at')->nullable();
            $table->timestamps();

            $table->index(['team', 'roster_date']);
        });
    }

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