Bugzilla – Attachment 141512 Details for
Bug 31673
DB update of bug 31086 fails: Cannot change column 'branchcode': used in a foreign key constraint
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31673: (bug 31086 follow-up) Drop and constraint to allow updating column
Bug-31673-bug-31086-follow-up-Drop-and-constraint-.patch (text/plain), 1.70 KB, created by
Martin Renvoize (ashimema)
on 2022-10-07 14:45:37 UTC
(
hide
)
Description:
Bug 31673: (bug 31086 follow-up) Drop and constraint to allow updating column
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-10-07 14:45:37 UTC
Size:
1.70 KB
patch
obsolete
>From 1ff4e4e3a05e2b3e843d7e1fa446ebcdf58f35f5 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 5 Oct 2022 10:16:02 +0000 >Subject: [PATCH] Bug 31673: (bug 31086 follow-up) Drop and constraint to allow > updating column > >It seems that we cannot edit the column while it has a constraint. >If we remove it, update the oclumn, then re-add it, the update succeeds > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > installer/data/mysql/db_revs/220600020.pl | 8 ++++++++ > 1 file changed, 8 insertions(+) > >diff --git a/installer/data/mysql/db_revs/220600020.pl b/installer/data/mysql/db_revs/220600020.pl >index ccd6a0a518..b023204410 100755 >--- a/installer/data/mysql/db_revs/220600020.pl >+++ b/installer/data/mysql/db_revs/220600020.pl >@@ -31,11 +31,19 @@ return { > UPDATE reserves SET branchcode = ( SELECT branchcode FROM branches LIMIT 1) WHERE branchcode IS NULL; > }); > >+ # Remove FOREIGN KEY CONSTRAINT >+ $dbh->do(q{ >+ ALTER TABLE reserves DROP FOREIGN KEY reserves_ibfk_4; >+ }); > # Set the NOT NULL configuration > $dbh->do(q{ > ALTER TABLE reserves > MODIFY COLUMN `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'foreign key from the branches table defining which branch the patron wishes to pick this hold up at' > }); >+ # Replace the constraint >+ $dbh->do(q{ >+ ALTER TABLE reserves ADD CONSTRAINT reserves_ibfk_4 FOREIGN KEY (branchcode) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE; >+ }); > > # Print useful stuff here > say $out "Removed NULL option from branchcode for reserves"; >-- >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 31673
:
141336
| 141512 |
141599