From d0d6e5fdeebf41d7dd6e10164431c6b810fdaf4e Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Thu, 27 Mar 2014 16:53:11 +0530 Subject: [PATCH] --CRM-14191, fixed the upgrade code and also added upgrade code to update civicrm_option_value.value for batch_status and batch_mode --- CRM/Upgrade/Incremental/sql/4.3.alpha1.mysql.tpl | 13 ++++++------- CRM/Upgrade/Incremental/sql/4.4.5.mysql.tpl | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/CRM/Upgrade/Incremental/sql/4.3.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.3.alpha1.mysql.tpl index a547a77f08..dd8510d6f8 100644 --- a/CRM/Upgrade/Incremental/sql/4.3.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.3.alpha1.mysql.tpl @@ -606,19 +606,18 @@ SELECT @weight := MAX(value) FROM civicrm_option_value WHERE opt INSERT INTO `civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`) VALUES - (@option_group_id_batch_status, {localize}'Data Entry'{/localize}, @weight = @weight + 1, 'Data Entry', NULL, 0, 0, @weight = @weight + 1), - (@option_group_id_batch_status, {localize}'Reopened'{/localize}, @weight = @weight + 1, 'Reopened', NULL, 0, 0, @weight = @weight + 1), - (@option_group_id_batch_status, {localize}'Exported'{/localize}, @weight = @weight + 1, 'Exported' , NULL, 0, 0, @weight = @weight + 1); + (@option_group_id_batch_status, {localize}'Data Entry'{/localize}, @weight + 1, 'Data Entry', NULL, 0, 0, @weight + 1), + (@option_group_id_batch_status, {localize}'Reopened'{/localize}, @weight + 2, 'Reopened', NULL, 0, 0, @weight + 2), + (@option_group_id_batch_status, {localize}'Exported'{/localize}, @weight + 3, 'Exported' , NULL, 0, 0, @weight + 3); -- Insert Batch Modes. +SELECT @option_group_id_batch_modes := max(id) from civicrm_option_group where name = 'batch_mode'; -SELECT @option_group_id_batch_modes := max(id) from civicrm_option_group where name = 'batch_mode'; -SELECT @weight := MAX(value) FROM civicrm_option_value WHERE option_group_id = @option_group_id_batch_status; INSERT INTO `civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`) VALUES - (@option_group_id_batch_modes, {localize}'Manual Batch'{/localize}, @weight = @weight + 1, 'Manual Batch', NULL, 0, 0, @weight = @weight + 1), - (@option_group_id_batch_modes, {localize}'Automatic Batch'{/localize}, @weight = @weight + 1, 'Automatic Batch' , NULL, 0, 0, @weight = @weight + 1); + (@option_group_id_batch_modes, {localize}'Manual Batch'{/localize}, 1, 'Manual Batch', NULL, 0, 0, 1), + (@option_group_id_batch_modes, {localize}'Automatic Batch'{/localize}, 2, 'Automatic Batch' , NULL, 0, 0, 2); -- End of civiaccounts upgrade diff --git a/CRM/Upgrade/Incremental/sql/4.4.5.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.4.5.mysql.tpl index d887e8b90b..5c57e2f1a7 100644 --- a/CRM/Upgrade/Incremental/sql/4.4.5.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.4.5.mysql.tpl @@ -1 +1,17 @@ {* file to handle db changes in 4.4.5 during upgrade *} +-- CRM-14191 +SELECT @option_group_id_batch_status := max(id) from civicrm_option_group where name = 'batch_status'; +SELECT @weight := MAX(value) FROM civicrm_option_value WHERE option_group_id = @option_group_id_batch_status; + +UPDATE civicrm_option_value +SET value = (Select @weight := @weight +1), +weight = @weight +where option_group_id = @option_group_id_batch_status AND name IN ('Data Entry', 'Reopened', 'Exported') AND value = 0 ORDER BY id; + +SELECT @option_group_id_batch_modes := max(id) from civicrm_option_group where name = 'batch_mode'; +SELECT @weights := MAX(value) FROM civicrm_option_value WHERE option_group_id = @option_group_id_batch_modes; + +UPDATE civicrm_option_value +SET value = (Select @weights := @weights +1), +weight = @weights +where option_group_id = @option_group_id_batch_modes AND name IN ('Manual Batch', 'Automatic Batch') AND value = 0; \ No newline at end of file -- 2.25.1