$this->fixSchemaDifferencesForALL();
}
// invoke the meta trigger creation call
- CRM_Core_DAO::triggerRebuild();
+ CRM_Core_DAO::triggerRebuild(NULL, TRUE);
}
/**
// for any obsolete columns (not null) we just make the column nullable.
if (!empty($cols['OBSOLETE'])) {
- $create = $this->_getCreateQuery("log_{$table}");
+ $create = $this->_getCreateQuery("`{$this->db}`.log_{$table}");
foreach ($cols['OBSOLETE'] as $col) {
$line = $this->_getColumnQuery($col, $create);
// This is just going to make a not null column to nullable
foreach ($this->tables as $table) {
if (empty($this->logs[$table])) {
$this->createLogTableFor($table);
- } else {
+ }
+ else {
$diffs[$table] = $this->columnsWithDiffSpecs($table, "log_$table");
}
}
/**
* Get an array of column names of the given table.
*/
- private function columnsOf($table) {
+ private function columnsOf($table, $force = FALSE) {
static $columnsOf = array();
$from = (substr($table, 0, 4) == 'log_') ? "`{$this->db}`.$table" : $table;
- if (!isset($columnsOf[$table])) {
+ if (!isset($columnsOf[$table]) || $force) {
CRM_Core_Error::ignoreException();
$dao = CRM_Core_DAO::executeQuery("SHOW COLUMNS FROM $from");
CRM_Core_Error::setCallback();
// NOTE: we consider only those columns for modifications where there is a spec change, and that the column definition
// wasn't deliberately modified by fixTimeStampAndNotNullSQL() method.
foreach ($civiTableSpecs as $col => $colSpecs) {
+ if ( !is_array($logTableSpecs[$col]) ) {
+ $logTableSpecs[$col] = array();
+ }
+
$specDiff = array_diff($civiTableSpecs[$col], $logTableSpecs[$col]);
if (!empty($specDiff) && $col != 'id' && !array_key_exists($col, $diff['ADD'])) {
// ignore 'id' column for any spec changes, to avoid any auto-increment mysql errors
return (bool) CRM_Core_DAO::singleValueQuery("SHOW TRIGGERS LIKE 'civicrm_contact'");
}
- function triggerInfo(&$info, $tableName = NULL) {
+ function triggerInfo(&$info, $tableName = NULL, $force = FALSE) {
// check if we have logging enabled
$config =& CRM_Core_Config::singleton();
if (!$config->logging) {
// logging is enabled, so now lets create the trigger info tables
foreach ($tableNames as $table) {
- $columns = $this->columnsOf($table);
+ $columns = $this->columnsOf($table, $force);
// only do the change if any data has changed
$cond = array( );