<?php

use App\Models\Achievement;
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::table('achievements', function (Blueprint $table) {
            $table->boolean('has_page')->default(false);
        });

        $achievements = [
            'airlines_alliances.all_skyteam',
            'airlines_alliances.all_oneworld',
            'airlines_alliances.all_star_alliance',
            'airlines_alliances.all_vanilla_alliance',
            'fun_challenges.airline_alphabet',
            'fun_challenges.airport_alphabet',
            'fun_challenges.brazilian_states',
            'fun_challenges.us_states',
            'fun_challenges.australian_states',
            'fun_challenges.chinese_provinces',
            'fun_challenges.canadian_provinces',
            'countries_continents.all_continent_pairs_one_way',
            'countries_continents.all_continent_pairs_both_ways',
        ];

        foreach($achievements as $achievement) {
            Achievement::where('internal_name', $achievement)->update(['has_page' => true]);
        }
    }

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