<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('hunts', function (Blueprint $table) {
            $table->unsignedSmallInteger('start_radius_m')->default(50)->after('longitude');
        });

        DB::table('hunt_participants')
            ->where('status', 'started')
            ->update(['status' => 'registered']);

        DB::table('hunt_participants')
            ->where('status', 'in_progress')
            ->where('current_step_number', 0)
            ->update(['status' => 'registered']);
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('hunts', function (Blueprint $table) {
            $table->dropColumn('start_radius_m');
        });
    }
};
