<?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('customers', function (Blueprint $table) {
            $table->dropIndex(['ip_address']);
            $table->string('ip_address', 191)->nullable()->change();
            $table->unique('ip_address', 'customers_pppoe_username_unique');
        });
        Schema::table('online_payment_transactions', function (Blueprint $table) {
            $table->string('ip_address', 191)->change();
        });
    }

    public function down(): void
    {
        Schema::table('customers', function (Blueprint $table) {
            $table->dropUnique('customers_pppoe_username_unique');
            $table->string('ip_address', 45)->nullable()->change();
            $table->index('ip_address');
        });
        Schema::table('online_payment_transactions', function (Blueprint $table) {
            $table->string('ip_address', 45)->change();
        });
    }
};
