<?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
    {
        $tables = ['clients', 'tenants', 'site_briefings', 'sites'];

        foreach ($tables as $table) {
            if (Schema::hasColumn($table, 'address')) {
                Schema::table($table, function (Blueprint $t) {
                    $t->string('address', 500)->nullable()->change();
                });
            }
        }
    }

    public function down(): void
    {
        $tables = ['clients', 'tenants', 'site_briefings', 'sites'];

        foreach ($tables as $table) {
            if (Schema::hasColumn($table, 'address')) {
                Schema::table($table, function (Blueprint $t) {
                    $t->string('address', 255)->nullable()->change();
                });
            }
        }
    }
};
