<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('tournaments', function (Blueprint $table) {
            $table->string('prize_1st')->nullable()->after('prize');
            $table->string('prize_2nd')->nullable()->after('prize_1st');
            $table->string('prize_3rd')->nullable()->after('prize_2nd');
        });

        // Migrate existing prize data to prize_1st
        DB::statement('UPDATE tournaments SET prize_1st = prize WHERE prize IS NOT NULL');
    }

    public function down(): void
    {
        Schema::table('tournaments', function (Blueprint $table) {
            $table->dropColumn(['prize_1st', 'prize_2nd', 'prize_3rd']);
        });
    }
};
