Bugzilla – Attachment 100547 Details for
Bug 21901
Foreign keys are missing on the serials and subscriptions tables
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21901: Add a warning if we removed entries
Bug-21901-Add-a-warning-if-we-removed-entries.patch (text/plain), 3.70 KB, created by
Martin Renvoize (ashimema)
on 2020-03-11 11:51:55 UTC
(
hide
)
Description:
Bug 21901: Add a warning if we removed entries
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-03-11 11:51:55 UTC
Size:
3.70 KB
patch
obsolete
>From 69ee2fb9673fa3de2b38f96e2eb2c64828ed5ffe Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 9 Mar 2020 15:25:29 +0100 >Subject: [PATCH] Bug 21901: Add a warning if we removed entries > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../data/mysql/atomicupdate/bug_21901.perl | 37 ++++++++++++++----- > 1 file changed, 28 insertions(+), 9 deletions(-) > >diff --git a/installer/data/mysql/atomicupdate/bug_21901.perl b/installer/data/mysql/atomicupdate/bug_21901.perl >index 5ea3bef734..e319f71a81 100644 >--- a/installer/data/mysql/atomicupdate/bug_21901.perl >+++ b/installer/data/mysql/atomicupdate/bug_21901.perl >@@ -34,9 +34,15 @@ if( CheckVersion( $DBversion ) ) { > |); > > unless ( foreign_key_exists( 'serial', 'serial_ibfk_1' ) ) { >- $dbh->do(q| >- DELETE FROM serial WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio) >- |); >+ my $serials = $dbh->selectall_arrayref(q| >+ SELECT serialid FROM serial WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio) >+ |, { Slice => {} }); >+ if ( @$serials ) { >+ warn q|WARNING - The following serials are deleted, they were not attached to an existing bibliographic record (serialid): | . join ", ", map { $_->{serialid} } @$serials; >+ $dbh->do(q| >+ DELETE FROM serial WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio) >+ |); >+ } > $dbh->do(q| > ALTER TABLE serial > ADD CONSTRAINT serial_ibfk_1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE >@@ -49,9 +55,15 @@ if( CheckVersion( $DBversion ) ) { > |); > > unless ( foreign_key_exists( 'serial', 'serial_ibfk_2' ) ) { >- $dbh->do(q| >- DELETE FROM serial WHERE subscriptionid NOT IN (SELECT subscriptionid FROM subscription) >- |); >+ my $serials = $dbh->selectall_arrayref(q| >+ SELECT serialid FROM serial WHERE subscriptionid NOT IN (SELECT subscriptionid FROM subscription) >+ |, { Slice => {} }); >+ if ( @$serials ) { >+ warn q|WARNING - The following serials are deleted, they were not attached to an existing subscription (serialid): | . join ", ", map { $_->{serialid} } @$serials; >+ $dbh->do(q| >+ DELETE FROM serial WHERE subscriptionid NOT IN (SELECT subscriptionid FROM subscription) >+ |); >+ } > $dbh->do(q| > ALTER TABLE serial > ADD CONSTRAINT serial_ibfk_2 FOREIGN KEY (subscriptionid) REFERENCES subscription (subscriptionid) ON DELETE CASCADE ON UPDATE CASCADE >@@ -90,9 +102,16 @@ if( CheckVersion( $DBversion ) ) { > |); > > unless ( foreign_key_exists( 'subscription', 'subscription_ibfk_3' ) ) { >- $dbh->do(q| >- DELETE FROM subscription WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio) >- |); >+ my $subscriptions = $dbh->selectall_arrayref(q| >+ SELECT subscriptionid FROM subscription WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio) >+ |, { Slice => {} }); >+ if ( @$subscriptions ) { >+ warn q|WARNING - The following subscriptions are deleted, they were not attached to an existing bibliographic record (subscriptionid): | . join ", ", map { $_->{subscriptionid} } @$subscriptions; >+ >+ $dbh->do(q| >+ DELETE FROM subscription WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio) >+ |); >+ } > $dbh->do(q| > ALTER TABLE subscription > ADD CONSTRAINT subscription_ibfk_3 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE >-- >2.20.1
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 21901
:
96181
|
98177
|
98229
|
98231
|
100384
|
100545
|
100546
|
100547
|
103122
|
103123
|
103124
|
103125
|
103151