<?php

if (!defined('sugarEntry') || !sugarEntry) {
    die('Not A Valid Entry Point');
}

// This runs after all modules tables are created via installerHook called on performSetup.php
// function post_createAllModuleTables(){
// return 'LionixCRM modules tables finished';
// }

// This runs after installation is completed via installerHook called on performSetup.php
function post_installModules()
{
    global $sugar_config;
    $db = DBManagerFactory::getInstance();

    $database = $sugar_config['dbconfig']['db_name'];
    $query = "
        SELECT TABLE_NAME
        FROM information_schema.tables
        WHERE table_schema = '{$database}'
            AND (TABLE_NAME LIKE '%cstm'
                 OR TABLE_NAME LIKE '%audit')
    ";
    $result = $db->query($query);

    while (($row = $db->fetchByAssoc($result)) != null) {
        $query = "ALTER TABLE {$row['table_name']} ADD lxcode_c int AUTO_INCREMENT NOT NULL UNIQUE";
        $db->query($query);
    }
    installLog('LionixCRM added lxcode_c to all custom and audit tables');

    installLog('LionixCRM install finished');

    return 'LionixCRM install finished';
}

Install Hooks to create LionixCRM lxcode_c field on audit and custom tables
feat: Install Hooks to create LionixCRM lxcode_c field on audit and custom tables
