Bugzilla – Attachment 140072 Details for
Bug 30490
Adjust foreign key for parent item type
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30490: Adjust constraint itemtypes.itemtypes_ibfk_1
Bug-30490-Adjust-constraint-itemtypesitemtypesibfk.patch (text/plain), 2.50 KB, created by
Nick Clemens (kidclamp)
on 2022-09-02 07:13:12 UTC
(
hide
)
Description:
Bug 30490: Adjust constraint itemtypes.itemtypes_ibfk_1
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-09-02 07:13:12 UTC
Size:
2.50 KB
patch
obsolete
>From 79c25f689b3fadcf773ac5d7857e343c994af4cf Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 23 Aug 2022 13:00:17 +0000 >Subject: [PATCH] Bug 30490: Adjust constraint itemtypes.itemtypes_ibfk_1 > >Change from CASCADE to restrict. >In harmony with dbrev 20.06.00.022. > >Test plan: >Run the dbrev. >Bonus: >update itemtypes set parent_type='VM' where itemtype='CF'; >delete from itemtypes where itemtype='VM'; >=> ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`koha_myclone`.`itemtypes`, CONSTRAINT `itemtypes_ibfk_1` FOREIGN KEY (`parent_type`) REFERENCES `itemtypes` (`itemtype`)) > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > installer/data/mysql/atomicupdate/bug_30490.pl | 18 ++++++++++++++++++ > installer/data/mysql/kohastructure.sql | 2 +- > 2 files changed, 19 insertions(+), 1 deletion(-) > create mode 100755 installer/data/mysql/atomicupdate/bug_30490.pl > >diff --git a/installer/data/mysql/atomicupdate/bug_30490.pl b/installer/data/mysql/atomicupdate/bug_30490.pl >new file mode 100755 >index 0000000000..9b5afad3a6 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_30490.pl >@@ -0,0 +1,18 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => 30490, >+ description => "Adjust FK constraint for parent item type", >+ up => sub { >+ my ($args) = @_; >+ my ($dbh, $out) = @$args{qw(dbh out)}; >+ if( foreign_key_exists('itemtypes', 'itemtypes_ibfk_1') ) { >+ $dbh->do(q{ >+alter table itemtypes drop foreign key itemtypes_ibfk_1; >+ }); >+ } >+ $dbh->do(q{ >+alter table itemtypes add foreign key itemtypes_ibfk_1 (`parent_type`) REFERENCES `itemtypes` (`itemtype`); >+ }); >+ }, >+}; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index affa80e9c2..a92bd52cae 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -3344,7 +3344,7 @@ CREATE TABLE `itemtypes` ( > PRIMARY KEY (`itemtype`), > UNIQUE KEY `itemtype` (`itemtype`), > KEY `itemtypes_ibfk_1` (`parent_type`), >- CONSTRAINT `itemtypes_ibfk_1` FOREIGN KEY (`parent_type`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE >+ CONSTRAINT `itemtypes_ibfk_1` FOREIGN KEY (`parent_type`) REFERENCES `itemtypes` (`itemtype`) > ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; > /*!40101 SET character_set_client = @saved_cs_client */; > >-- >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 30490
:
139678
| 140072