<?php

use App\Enums\ContestStatusEnum;
use App\Enums\DifficultyLevelEnums;
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('contests', function (Blueprint $table) {
            $table->id();
            $table->foreignIdFor(\App\Models\ContestCategory::class, 'category_id')->constrained()->cascadeOnDelete();
            $table->string('image')->nullable();
            $table->enum('contest_level', DifficultyLevelEnums::values())->default(DifficultyLevelEnums::BEGINNER);
            $table->timestamp('start_time')->nullable();
            $table->timestamp('end_time')->nullable();
            $table->string('banner_image')->nullable();
            $table->boolean('is_free')->default(false); // indicates if the contest is free to participate
            $table->unsignedBigInteger('entry_fee')->default(0); // entry fee for the contest, if applicable
            $table->boolean('is_featured')->default(false); // indicates if the contest is featured
            $table->unsignedInteger('participant_limit')->nullable(); // limit on the number of participants
            $table->enum('status', ContestStatusEnum::values())->default(ContestStatusEnum::UPCOMING);
            $table->timestamps();
        });
    }

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