<?php

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
    {
        //Update Virgin Australia's ICAO Code
        DB::table('airlines')
            ->where('IATA_code', 'VA')
            ->where('internal_name', 'virgin-australia')
            ->update(['ICAO_code' => 'VOZ']);

        DB::table('airlines')->insert([
            'IATA_code'     => 'VA',
            'ICAO_code'     => 'VAU',
            'name'          => 'V Australia',
            'internal_name' => 'v-australia',
            'country_code'  => 'AU',
            'country_name'  => 'Australia',
            'active'        => false,
            'logo'          => 'VA_2.png',
        ]);
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        DB::table('airlines')
            ->where('IATA_code', 'VA')
            ->where('internal_name', 'virgin-australia')
            ->update(['ICAO_code' => 'VAU']);

        DB::table('airlines')->where('internal_name', 'v-australia')->delete();
    }
};
