<?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
    {
        // Rename columns in company_registrations table
        Schema::table('company_registrations', function (Blueprint $table) {
            $table->renameColumn('identity_card_number_encrypted', 'nin_number_encrypted');
            $table->renameColumn('identity_card_number_iv', 'nin_number_iv');
            $table->renameColumn('identity_card_number_tag', 'nin_number_tag');
        });

        // Rename columns in company_registration_updates table
        Schema::table('company_registration_updates', function (Blueprint $table) {
            $table->renameColumn('identity_card_number_encrypted', 'nin_number_encrypted');
            $table->renameColumn('identity_card_number_iv', 'nin_number_iv');
            $table->renameColumn('identity_card_number_tag', 'nin_number_tag');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        // Revert column names in company_registrations table
        Schema::table('company_registrations', function (Blueprint $table) {
            $table->renameColumn('nin_number_encrypted', 'identity_card_number_encrypted');
            $table->renameColumn('nin_number_iv', 'identity_card_number_iv');
            $table->renameColumn('nin_number_tag', 'identity_card_number_tag');
        });

        // Revert column names in company_registration_updates table
        Schema::table('company_registration_updates', function (Blueprint $table) {
            $table->renameColumn('nin_number_encrypted', 'identity_card_number_encrypted');
            $table->renameColumn('nin_number_iv', 'identity_card_number_iv');
            $table->renameColumn('nin_number_tag', 'identity_card_number_tag');
        });
    }
};
