function setNewType( $cli, $db, $newType, $usecopy )
{
    $tables = $db->arrayQuery( "show tables" );

    foreach ( $tables as $table )
    {
        $tableName = current( $table );

        // Checking if it is necessary to convert the table.
        if ( strncmp( $tableName, "ez", 2 ) != 0 )
        {
            $cli->notice( "Skipping table $tableName because it is not an eZ Publish table" );
        }
        else if ( strcasecmp( getTableType( $db, $tableName ), $newType ) == 0 )
        {
            $cli->notice( "Skipping table $tableName because it has already the $newType type" );
        }
        else
        {
            // Yes, convert.
            $cli->output( "Converting table $tableName ... " );

            if ( !$usecopy )
            {
                // The simple one
                alterType( $db, $tableName, $newType );
            }
            else
            {
                renameTable( $db, $tableName, "eztemp__$tableName" );
                createTableStructure( $db, "eztemp__$tableName", $tableName, $newType );
                copyTable( $db, "eztemp__$tableName", $tableName );
                dropTable( $db, "eztemp__$tableName" );
            }
        }
    }
}
<?php

/**
 * @author Amasty Team
 * @copyright Copyright (c) 2015 Amasty (https://www.amasty.com)
 * @package Amasty_Audit
 */
$installer = $this;
/* @var $installer Mage_Core_Model_Resource_Setup */
$installer->startSetup();
$allTablesSql = 'SHOW TABLES';
$allTables = $installer->getConnection()->fetchCol($allTablesSql);
function renameTable($allTables, $inputTable, $outputTable, $installer)
{
    $inputTableName = Mage::getSingleton("core/resource")->getTableName($inputTable);
    $outputTableName = Mage::getSingleton("core/resource")->getTableName($outputTable);
    if (!in_array($outputTableName, $allTables)) {
        if (in_array($inputTableName, $allTables)) {
            $installer->run("\n\t\t\t\tRENAME TABLE `{$inputTableName}` TO `{$outputTableName}`\n\t\t\t");
        }
    }
}
$auditTableLocation = "amasty_audit_location";
$auditTableBlock = "amasty_audit_block";
$geoTableLocation = "amasty_geoip_location";
$geoTableBlock = "amasty_geoip_block";
renameTable($allTables, $auditTableLocation, $geoTableLocation, $installer);
renameTable($allTables, $auditTableBlock, $geoTableBlock, $installer);
$installer->run("\n\nUPDATE `{$installer->getTable('core/config_data')}`\n\t\t\t   SET path = 'amgeoip/import/block'\n\t\t\t   WHERE path = 'amaudit/import/block';\n\nUPDATE `{$installer->getTable('core/config_data')}`\n\t\t\t   SET path = 'amgeoip/import/location'\n\t\t\t   WHERE path = 'amaudit/import/location';\n\nCREATE TABLE IF NOT EXISTS `{$installer->getTable('amaudit/active')}` (\n\t`entity_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t`data_id` INT(10) UNSIGNED NOT NULL,\n\t`session_id` VARCHAR(255) NOT NULL,\n\t`recent_activity` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\tPRIMARY KEY (`entity_id`)\n)\nCOLLATE='utf8_general_ci'\nENGINE=InnoDB\nAUTO_INCREMENT=23\n;\n\n\n");
$installer->endSetup();