<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('person_addresses', function (Blueprint $table): void {
            $table->string('post_code', 16)->nullable();
            $table->string('city', 100)->nullable();
        });
    }

    public function down(): void
    {
        Schema::table('person_addresses', function (Blueprint $table): void {
            if (Schema::hasColumn('person_addresses', 'post_code')) {
                $table->dropColumn('post_code');
            }
            if (Schema::hasColumn('person_addresses', 'city')) {
                $table->dropColumn('city');
            }
        });
    }
};
