@@ -, +, @@ - Apply patch - Run updatedatabase - verify no error message - Run updatedatabase again - verify still no error message - Add a subscription and select a notice template for patron notification - Log in as any patron (not yourself) and subscribe to the email alert in the OPAC - Veriy on the subscription detail page, that the patron is subscribed in staff - Note borrowernumber and delete patron - SELECT * from alert; in a report - There should no longer be an entry with the borrowernumber - Start fresh with the web installer, verify there are no errors on creating the database tables --- .../data/mysql/atomicupdate/bug_13535_alert_constraint.perl | 11 +++++++++++ installer/data/mysql/kohastructure.sql | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_13535_alert_constraint.perl --- a/installer/data/mysql/atomicupdate/bug_13535_alert_constraint.perl +++ a/installer/data/mysql/atomicupdate/bug_13535_alert_constraint.perl @@ -0,0 +1,11 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + unless ( foreign_key_exists( 'alert', 'alert_ibfk_1' ) ) { + $dbh->do( + qq{ + ALTER TABLE alert ADD CONSTRAINT alert_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON UPDATE CASCADE ON DELETE CASCADE + } + ); + } + NewVersion( $DBversion, 13535, "Add FK constraint on borrowernumber to alert table"); +} --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -2768,7 +2768,8 @@ CREATE TABLE `alert` ( `externalid` varchar(20) NOT NULL default '', PRIMARY KEY (`alertid`), KEY `borrowernumber` (`borrowernumber`), - KEY `type` (`type`,`externalid`) + KEY `type` (`type`,`externalid`), + CONSTRAINT alert_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- --