X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FLogging%2FSchema.php;h=9a8e7133a216cb1f42fa2cf31ec8c0c4fcdd991a;hb=2fabb51bd1669c94ca0c62f5b4ca23089f17e53f;hp=ea6da26505b864e2dc9d13a2b286e56c0737b452;hpb=fa4dd075e22fd89b10a833fe571c2041af292a34;p=civicrm-core.git diff --git a/CRM/Logging/Schema.php b/CRM/Logging/Schema.php index ea6da26505..9a8e7133a2 100644 --- a/CRM/Logging/Schema.php +++ b/CRM/Logging/Schema.php @@ -1,34 +1,18 @@ columnsWithDiffSpecs($table, "log_$table"); } + // If a column that already exists on logging table is being added, we + // should treat it as a modification. + $this->resetSchemaCacheForTable("log_$table"); + $logTableSchema = $this->columnSpecsOf("log_$table"); + foreach ($cols['ADD'] as $colKey => $col) { + if (array_key_exists($col, $logTableSchema)) { + $cols['MODIFY'][] = $col; + unset($cols['ADD'][$colKey]); + } + } + // use the relevant lines from CREATE TABLE to add colums to the log table $create = $this->_getCreateQuery($table); foreach ((['ADD', 'MODIFY']) as $alterType) { @@ -467,9 +462,21 @@ AND (TABLE_NAME LIKE 'log_civicrm_%' $nonStandardTableNameString ) } } + $this->resetSchemaCacheForTable("log_$table"); + return TRUE; } + /** + * Resets schema cache for the given table. + * + * @param string $table + * Name of the table. + */ + private function resetSchemaCacheForTable($table) { + unset(\Civi::$statics[__CLASS__]['columnSpecs'][$table]); + } + /** * Get query table. * @@ -767,7 +774,7 @@ WHERE table_schema IN ('{$this->db}', '{$civiDB}')"; // rewrite the queries into CREATE TABLE queries for log tables: $cols = <<