<?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('match_events', function (Blueprint $table) {
            $table->id();
            $table->foreignId('match_id')->constrained('matches')->cascadeOnDelete();
            $table->enum('type', ['goal', 'yellow', 'red', 'sub', 'kickoff', 'halftime', 'fulltime', 'penalty', 'owngoal']);
            $table->enum('side', ['home', 'away']);
            $table->string('player')->nullable();
            $table->string('assist')->nullable();
            $table->string('player_in')->nullable();
            $table->string('player_out')->nullable();
            $table->string('description')->nullable();
            $table->enum('goal_kind', ['regular', 'penalty', 'owngoal'])->nullable();
            $table->unsignedSmallInteger('minute')->default(0);
            $table->unsignedSmallInteger('second')->default(0);
            $table->boolean('hidden')->default(false);
            $table->string('team_name')->nullable();
            $table->timestamps();
        });
    }

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