<?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('teams', function (Blueprint $table) {
            $table->id();
            $table->foreignId('season_id')->constrained('seasons')->cascadeOnDelete();
            $table->string('slug', 60)->unique();
            $table->string('name', 120);
            $table->unsignedBigInteger('captain_id')->nullable();
            $table->string('crest_shape', 20)->default('shield');
            $table->string('crest_motif', 30)->default('star');
            $table->string('crest_primary', 7)->default('#b21e2e');
            $table->string('crest_secondary', 7)->default('#0e0e10');
            $table->string('crest_initials', 2)->default('XX');
            $table->timestamps();

            $table->unique(['season_id', 'name']);
            $table->index('captain_id');
        });
    }

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