--CRM-14191, fixed the upgrade code and also added upgrade code to update civicrm_opt...
authorPradeep Nayak <pradeep.nayak@webaccess.co.in>
Thu, 27 Mar 2014 11:23:11 +0000 (16:53 +0530)
committerPradeep Nayak <pradeep.nayak@webaccess.co.in>
Thu, 27 Mar 2014 11:23:11 +0000 (16:53 +0530)
CRM/Upgrade/Incremental/sql/4.3.alpha1.mysql.tpl
CRM/Upgrade/Incremental/sql/4.4.5.mysql.tpl

index a547a77f08a3c4cb311af8f7d86093284c1db3a1..dd8510d6f8fdb56a69570f9c1663ef0273bc3d67 100644 (file)
@@ -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
 
index d887e8b90b97e5462cd643f46edd57c85cd1af14..5c57e2f1a72bc8460a9b0a38c5864fb932705f35 100644 (file)
@@ -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