From: Seamus Lee Date: Sat, 11 Feb 2023 05:14:19 +0000 (+1100) Subject: dev/core#4116 Add in rebuilding log table schema when modifying schema X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=80e0083bcc71915dea0f86fec2227f943b9186f3;p=civicrm-core.git dev/core#4116 Add in rebuilding log table schema when modifying schema Only rebuild if logging is enabled --- diff --git a/CRM/Upgrade/Incremental/Base.php b/CRM/Upgrade/Incremental/Base.php index 2dc039a4bd..7e6f85142a 100644 --- a/CRM/Upgrade/Incremental/Base.php +++ b/CRM/Upgrade/Incremental/Base.php @@ -225,7 +225,9 @@ class CRM_Upgrade_Incremental_Base { // Hrm, `enable()` normally does these things... but not during upgrade... // Note: A good test-scenario is to install 5.45; enable logging and CiviGrant; disable searchkit+afform; then upgrade to 5.47. $schema = new CRM_Logging_Schema(); - $schema->fixSchemaDifferences(); + if ($schema->isEnabled()) { + $schema->fixSchemaDifferences(); + } CRM_Core_Invoke::rebuildMenuAndCaches(FALSE, FALSE); // sessionReset is FALSE because upgrade status/postUpgradeMessages are needed by the page. We reset later in doFinish(). @@ -299,6 +301,10 @@ class CRM_Upgrade_Incremental_Base { foreach ($queries as $query) { CRM_Core_DAO::executeQuery($query, [], TRUE, NULL, FALSE, FALSE); } + $schema = new CRM_Logging_Schema(); + if ($schema->isEnabled()) { + $schema->fixSchemaDifferencesFor($table); + } } if ($locales && $triggerRebuild) { CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales, $version, TRUE); @@ -517,6 +523,10 @@ class CRM_Upgrade_Incremental_Base { CRM_Core_DAO::executeQuery("ALTER TABLE `$table` DROP COLUMN `$column`", [], TRUE, NULL, FALSE, FALSE); } + $schema = new CRM_Logging_Schema(); + if ($schema->isEnabled()) { + $schema->fixSchemaDifferencesFor($table); + } return TRUE; } @@ -599,6 +609,10 @@ class CRM_Upgrade_Incremental_Base { foreach ($queries as $query) { CRM_Core_DAO::executeQuery($query, [], TRUE, NULL, FALSE, FALSE); } + $schema = new CRM_Logging_Schema(); + if ($schema->isEnabled()) { + $schema->fixSchemaDifferencesFor($table); + } return TRUE; }