From be2faa1d0a8ad176b558d969b7e297f01c5af202 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 12 Oct 2017 15:31:21 +0100 Subject: [PATCH] CRM/Upgrade - Make the Tajikistan change replayable --- CRM/Upgrade/Incremental/php/FourSeven.php | 23 ++++++++++++++++++++ CRM/Upgrade/Incremental/sql/4.7.26.mysql.tpl | 5 ----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index a80352a4cb..cf71dc5dc2 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -447,6 +447,7 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base */ public function upgrade_4_7_26($rev) { $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev); + $this->addTask('CRM-21234 Missing subdivisions of Tajikistan', 'tajikistanMissingSubdivisions'); $this->addTask('CRM-20892 - Add modified_date to civicrm_mailing', 'addColumn', 'civicrm_mailing', 'modified_date', "timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When the mailing (or closely related entity) was created or modified or deleted.'"); $this->addTask('CRM-21195 - Add icon field to civicrm_navigation', 'addColumn', @@ -1247,6 +1248,28 @@ FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_ return TRUE; } + /** + * Add in missing Tajikistan Subdivisions + * + * @param \CRM_Queue_TaskContext $ctx + * + * @return bool + */ + public static function tajikistanMissingSubdivisions(CRM_Queue_TaskContext $ctx) { + $sql = 'INSERT INTO civicrm_state_province (id, country_id, abbreviation, name) VALUES'; + $updates = array(); + if (!CRM_Core_DAO::singleValueQuery("Select id FROM civicrm_state_province WHERE country_id = 1209 AND name = 'Dushanbe'")) { + $updates[] = '(NULL, 1209, "DU", "Dushanbe")'; + } + if (!CRM_Core_DAO::singleValueQuery("Select id FROM civicrm_state_province WHERE country_id = 1209 AND name = 'Nohiyahoi Tobei Jumhurí'")) { + $updates[] = '(NULL, 1209, "RA", "Nohiyahoi Tobei Jumhurí")'; + } + if (!empty($updates)) { + CRM_Core_DAO::executeQuery($sql . implode(', ', $updates)); + } + return TRUE; + } + /** * Remove the contribution logging reports which have been broken for a very long time. * diff --git a/CRM/Upgrade/Incremental/sql/4.7.26.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.7.26.mysql.tpl index 55168d405a..b9310381e7 100644 --- a/CRM/Upgrade/Incremental/sql/4.7.26.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.7.26.mysql.tpl @@ -2,8 +2,3 @@ -- CRM-20892 Change created_date default so that we can add a modified_date column ALTER TABLE civicrm_mailing CHANGE created_date created_date timestamp NULL DEFAULT NULL COMMENT 'Date and time this mailing was created.'; - --- CRM-21234 Missing subdivisions of Tajikistan. - INSERT INTO civicrm_state_province (id, country_id, abbreviation, name) VALUES - (NULL, 1209, "DU", "Dushanbe"), - (NULL, 1209, "RA", "Nohiyahoi Tobei Jumhurí"); -- 2.25.1