Bugzilla – Attachment 15914 Details for
Bug 8956
Split serials enumeration data into separate fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8956 - Split serials enumeration data into separate fields - Part 1 - Add fields to DB
Bug-8956---Split-serials-enumeration-data-into-sep.patch (text/plain), 3.59 KB, created by
Kyle M Hall (khall)
on 2013-03-06 18:45:06 UTC
(
hide
)
Description:
Bug 8956 - Split serials enumeration data into separate fields - Part 1 - Add fields to DB
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2013-03-06 18:45:06 UTC
Size:
3.59 KB
patch
obsolete
>From e4e5c436b11d9067f3b4f2369ad12f6e85491483 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 23 Oct 2012 14:48:41 -0400 >Subject: [PATCH] Bug 8956 - Split serials enumeration data into separate fields - Part 1 - Add fields to DB > >--- > installer/data/mysql/updatedatabase.pl | 70 ++++++++++++++++++++++++++++++++ > 1 files changed, 70 insertions(+), 0 deletions(-) > >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 7e5e243..85fbcdf 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -6444,6 +6444,76 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.11.00.XXX"; >+if (C4::Context->preference("Version") < TransformToNum($DBversion)) { >+ $dbh->do("ALTER TABLE serial ADD published_end_date DATE NULL DEFAULT NULL AFTER publisheddate"); >+ $dbh->do(" >+ ALTER TABLE serial ADD serialseq_x VARCHAR( 100 ) NULL DEFAULT NULL AFTER serialseq, >+ ADD serialseq_y VARCHAR( 100 ) NULL DEFAULT NULL AFTER serialseq_x, >+ ADD serialseq_z VARCHAR( 100 ) NULL DEFAULT NULL AFTER serialseq_y >+ "); >+ $dbh->do(" >+ ALTER TABLE subscription ADD serialseq_x_label VARCHAR( 100 ) NULL DEFAULT NULL AFTER numberingmethod, >+ ADD serialseq_y_label VARCHAR( 100 ) NULL DEFAULT NULL AFTER serialseq_x_label, >+ ADD serialseq_z_label VARCHAR( 100 ) NULL DEFAULT NULL AFTER serialseq_y_label >+ "); >+ >+ my $trim = sub { >+ my $string = shift; >+ $string =~ s/^\s+//; >+ $string =~ s/\s+$//; >+ return $string; >+ }; >+ >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare("SELECT * FROM subscription ORDER BY numberingmethod ASC"); >+ $sth->execute(); >+ while ( my $subscription = $sth->fetchrow_hashref() ) { >+ ## parse out the labels and save them >+ my $nm = $subscription->{'numberingmethod'}; >+ print "NUMBERING METHOD: '$nm'\n"; >+ my @labels = split(/\{[XYZ]\}[, ]?/, $nm); >+ @labels = map( $trim->( $_ ), @labels ); >+ my ( $x_label, $y_label, $z_label ) = @labels; >+ >+ $dbh->do( >+ "UPDATE subscription SET serialseq_x_label = ?, serialseq_y_label = ?, serialseq_z_label = ? WHERE subscriptionid = ?", >+ undef, >+ ( $x_label, $y_label, $z_label, $subscription->{'subscriptionid'} ) >+ ); >+ >+ ## parse of the data and save >+ my @splits = split(/\{[XYZ]\}/, $nm); >+ foreach my $s ( @splits ) { >+ $s = quotemeta( $s ); >+ } >+ >+ my $sth2 = $dbh->prepare("SELECT * FROM serial WHERE subscriptionid = ?"); >+ $sth2->execute( $subscription->{'subscriptionid'} ); >+ while( my $serial = $sth2->fetchrow_hashref() ) { >+ my $serialseq = $serial->{'serialseq'}; >+ my ( $x, $y, $z ); >+ ## We cannot split on multiple values at once, >+ ## so let's replace each of those values with __SPLIT__ >+ if ( @splits ) { >+ map( $serialseq =~ s/$_/__SPLIT__/ , @splits ); >+ ( undef, $x, $y, $z ) = split(/__SPLIT__/, $serialseq); >+ } else { ## Nothing to split on means the only thing in serialseq is {X} >+ $x = $serialseq; >+ } >+ >+ $dbh->do( >+ "UPDATE serial SET serialseq_x = ?, serialseq_y = ?, serialseq_z = ? WHERE serialid = ?", >+ undef, >+ ( $x, $y, $z, $serial->{'serialid'} ) >+ ); >+ } >+ } >+ >+ print "Upgrade to $DBversion done ( Split serials enumeration data into separate fields )\n"; >+ SetVersion ($DBversion); >+ >+} > > =head1 FUNCTIONS > >-- >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 8956
:
13041
|
13042
|
13043
|
13044
|
13045
|
13046
|
13047
|
15914
|
15915
|
15916
|
15917
|
15918
|
15919
|
15920
|
16346
|
16347
|
16348
|
16349
|
16350
|
16351
|
16352
|
16353
|
18554
|
18555
|
18556
|
18557
|
18558
|
18559
|
18560
|
18561
|
18568
|
18569
|
18570
|
18571
|
18572
|
18573
|
18574
|
18575
|
18576
|
18577
|
18578
|
18579
|
18580
|
18581
|
18582
|
18583
|
18679