Bugzilla – Attachment 144428 Details for
Bug 32399
Database update for bug 30483 is failing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32399: Unset foreign key checks while changing issues constraint
Bug-32399-Unset-foreign-key-checks-while-changing-.patch (text/plain), 2.31 KB, created by
Marcel de Rooy
on 2022-12-05 09:55:47 UTC
(
hide
)
Description:
Bug 32399: Unset foreign key checks while changing issues constraint
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2022-12-05 09:55:47 UTC
Size:
2.31 KB
patch
obsolete
>From 5f4b24e97494c92b09e35247a31bdf5611c01091 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 5 Dec 2022 09:18:04 +0000 >Subject: [PATCH] Bug 32399: Unset foreign key checks while changing issues > constraint >Content-Type: text/plain; charset=utf-8 > >Some users have reported that the dbrev of bug 30483 fails. This might >depend on bad data, SQL server version, etc. >The easiest workaround is now to unset the check temporarily. >Maybe we should also warn for issues without itemnumber or >borrowernumber on About? Or remove them? > >Test plan: >Reset your version in order to pass this dbrev again. So below >22.06.00.041. >* update systempreferences set value='22.0600040' where variable = 'Version'; >Run updatedatabase. > >Bonus: Create an issues record with invalid itemnumber (set FK check >off when doing so). Verify that dbrev prints warning about it. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > installer/data/mysql/db_revs/220600041.pl | 9 +++++++++ > 1 file changed, 9 insertions(+) > >diff --git a/installer/data/mysql/db_revs/220600041.pl b/installer/data/mysql/db_revs/220600041.pl >index 1d3f498f4e..f7a9133885 100755 >--- a/installer/data/mysql/db_revs/220600041.pl >+++ b/installer/data/mysql/db_revs/220600041.pl >@@ -6,10 +6,19 @@ return { > up => sub { > my ($args) = @_; > my ($dbh, $out) = @$args{qw(dbh out)}; >+ # Count bad records (expecting zero..) >+ my ( $cnt ) = $dbh->selectrow_array(q{ >+ SELECT COUNT(issue_id) FROM issues >+ LEFT JOIN borrowers USING (borrowernumber) >+ LEFT JOIN items USING (itemnumber) >+ WHERE items.itemnumber IS NULL OR borrowers.borrowernumber IS NULL }); >+ $dbh->do('SET FOREIGN_KEY_CHECKS=0'); > $dbh->do(q{ > ALTER TABLE issues > MODIFY COLUMN borrowernumber int(11) NOT NULL COMMENT 'foreign key, linking this to the borrowers table for the patron this item was checked out to', > MODIFY COLUMN itemnumber int(11) NOT NULL COMMENT 'foreign key, linking this to the items table for the item that was checked out' > }); >+ $dbh->do('SET FOREIGN_KEY_CHECKS=1'); >+ say $out "WARNING: Your issues table contains $cnt records with invalid borrowernumber or itemnumber. Please correct/remove them." if $cnt; > }, > }; >-- >2.30.2
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 32399
:
144428
|
144448
|
144516
|
144616
|
149235