<?php

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

/**
 * Clear stale current_version values from installer-detected servers
 * that have no file_id. These are full filenames from the modpack
 * installer that aren't valid for version comparison.
 */
return new class extends Migration
{
    public function up(): void
    {
        DB::table('modpackchecker_servers')
            ->where('detection_method', 'installer')
            ->whereNull('current_file_id')
            ->update([
                'current_version' => null,
                'status' => 'pending_calibration',
            ]);
    }

    public function down(): void
    {
        // No rollback — data was stale
    }
};
