<?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('matches', function (Blueprint $table) {
            $table->id();
            $table->foreignId('home_team_id')->constrained('teams');
            $table->foreignId('away_team_id')->constrained('teams');
            $table->dateTime('date');
            $table->string('venue')->nullable();
            $table->string('competition')->default('Приятелски');
            $table->enum('status', ['scheduled', 'live', 'finished'])->default('scheduled');
            $table->unsignedSmallInteger('score_home')->default(0);
            $table->unsignedSmallInteger('score_away')->default(0);
            $table->enum('period', ['pre', 'first', 'halftime', 'second', 'full'])->default('pre');
            $table->float('timer_accumulated')->default(0);
            $table->dateTime('timer_started_at')->nullable();
            $table->boolean('running')->default(false);
            $table->boolean('show_overlay')->default(true);
            $table->unsignedSmallInteger('extra_time')->default(0);
            $table->json('popup')->nullable();
            $table->string('notes')->nullable();
            $table->timestamps();
        });
    }

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