Bugzilla – Attachment 37363 Details for
Bug 13380
Auto fill order cancellation reasons from authorised values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 13380: Follow-up - only run database update, when it hasn't been run already
PASSED-QA-Bug-13380-Follow-up---only-run-database-.patch (text/plain), 4.46 KB, created by
Kyle M Hall (khall)
on 2015-03-30 11:20:05 UTC
(
hide
)
Description:
[PASSED QA] Bug 13380: Follow-up - only run database update, when it hasn't been run already
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-03-30 11:20:05 UTC
Size:
4.46 KB
patch
obsolete
>From 428144cfbe1356bf95899a12ba9293885d6da039 Mon Sep 17 00:00:00 2001 >From: Katrin Fischer <Katrin.Fischer.83@web.de> >Date: Mon, 23 Mar 2015 21:42:14 +0100 >Subject: [PATCH] [PASSED QA] Bug 13380: Follow-up - only run database update, when it hasn't been run already > >As the ORDER_CANCELLATION_REASON authorised value has been >backported to 3.18.5, we need to make sure that the database >update is only run once. > >This patch adds a check for the existance of the authorised >value in order to decide if the databaes update can be run. > >To test: >- Create a branch 3.19.00.016 >- Make sure you have a few orders where the cancellationreason > is set (cancel an order, enter a reason) >- Update your branch to master + this patch >- Run the web installer >- ORDER_CANCELLATION_REASON authorised value category is created >- Reset your system preference Version to 3.19.00.015 >- Run database update again - no changes are made, all is fine > >Or: >- Create a branch 3.18.04 with cancelled orders >- Update to latest 3.18.x >- Make sure ORDER_CANCELLATION_REASON has been created >- Dump database >- Switch to master without this patch >- Run update - verify more O_C_R were created (bad) >- Load database >- Update to master with this patch >- All should be fine > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > installer/data/mysql/updatedatabase.pl | 59 ++++++++++++++++++-------------- > 1 files changed, 33 insertions(+), 26 deletions(-) > >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 951060f..a818f51 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -9834,36 +9834,43 @@ if ( CheckVersion($DBversion) ) { > > $DBversion = "3.19.00.016"; > if(CheckVersion($DBversion)) { >- $dbh->do(q{ >- INSERT INTO authorised_values (category, authorised_value, lib) VALUES >- ('ORDER_CANCELLATION_REASON', 0, 'No reason provided'), >- ('ORDER_CANCELLATION_REASON', 1, 'Out of stock'), >- ('ORDER_CANCELLATION_REASON', 2, 'Restocking') >- }); >+ my @order_cancellation_reason = $dbh->selectrow_array("SELECT count(*) FROM authorised_values WHERE category='ORDER_CANCELLATION_REASON'"); >+ if ($order_cancellation_reason[0] == 0) { >+ $dbh->do(q{ >+ INSERT INTO authorised_values (category, authorised_value, lib) VALUES >+ ('ORDER_CANCELLATION_REASON', 0, 'No reason provided'), >+ ('ORDER_CANCELLATION_REASON', 1, 'Out of stock'), >+ ('ORDER_CANCELLATION_REASON', 2, 'Restocking') >+ }); > >- my $already_existing_reasons = $dbh->selectcol_arrayref(q{ >- SELECT DISTINCT( cancellationreason ) >- FROM aqorders; >- }, { Slice => {} }); >+ my $already_existing_reasons = $dbh->selectcol_arrayref(q{ >+ SELECT DISTINCT( cancellationreason ) >+ FROM aqorders; >+ }, { Slice => {} }); > >- my $update_orders_sth = $dbh->prepare(q{ >- UPDATE aqorders >- SET cancellationreason = ? >- WHERE cancellationreason = ? >- }); >+ my $update_orders_sth = $dbh->prepare(q{ >+ UPDATE aqorders >+ SET cancellationreason = ? >+ WHERE cancellationreason = ? >+ }); > >- my $insert_av_sth = $dbh->prepare(q{ >- INSERT INTO authorised_values (category, authorised_value, lib) VALUES >- ('ORDER_CANCELLATION_REASON', ?, ?) >- }); >- my $i = 3; >- for my $reason ( @$already_existing_reasons ) { >- next unless $reason; >- $insert_av_sth->execute( $i, $reason ); >- $update_orders_sth->execute( $i, $reason ); >- $i++; >+ my $insert_av_sth = $dbh->prepare(q{ >+ INSERT INTO authorised_values (category, authorised_value, lib) VALUES >+ ('ORDER_CANCELLATION_REASON', ?, ?) >+ }); >+ my $i = 3; >+ for my $reason ( @$already_existing_reasons ) { >+ next unless $reason; >+ $insert_av_sth->execute( $i, $reason ); >+ $update_orders_sth->execute( $i, $reason ); >+ $i++; >+ } >+ print "Upgrade to $DBversion done (Bug 13380: Add the ORDER_CANCELLATION_REASON authorised value)\n"; >+ } >+ else { >+ print "Upgrade to $DBversion done (Bug 13380: ORDER_CANCELLATION_REASON authorised value already existed from earlier update!)\n"; > } >- print "Upgrade to $DBversion done (Bug 13380: Add the ORDER_CANCELLATION_REASON authorised value)\n"; >+ > SetVersion($DBversion); > } > >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13380
:
34090
|
34091
|
34140
|
34746
|
34747
|
35695
|
35696
|
35767
|
35768
|
35773
|
37144
|
37163
|
37179
| 37363