@@ -, +, @@ auth_subfield_structure.authtypecode SELECT COUNT(*) FROM auth_subfield_structure WHERE authtypecode='RM_ME'; - Works exactly as described in the (very good) test plan. - After authority type deletion, auth_subfield_structure still contains entries for deleted authority type. Applying the patch clean the previously undeleted records in auth_subfield_strucute. Now deleting a authority type cleans propertly all appropriate records in auth_subfield_structure. - Fix a merge conflict --- installer/data/mysql/kohastructure.sql | 3 ++- installer/data/mysql/updatedatabase.pl | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -58,7 +58,8 @@ CREATE TABLE `auth_subfield_structure` ( `frameworkcode` varchar(10) NOT NULL default '', `defaultvalue` TEXT DEFAULT '', PRIMARY KEY (`authtypecode`,`tagfield`,`tagsubfield`), - KEY `tab` (`authtypecode`,`tab`) + KEY `tab` (`authtypecode`,`tab`), + CONSTRAINT `auth_subfield_structure_ibfk_1` FOREIGN KEY (`authtypecode`) REFERENCES `auth_types` (`authtypecode`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -10142,6 +10142,25 @@ if(CheckVersion($DBversion)) { SetVersion($DBversion); } +$DBversion = "3.19.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do(q{ + DELETE ass.* + FROM auth_subfield_structure AS ass + LEFT JOIN auth_types USING(authtypecode) + WHERE auth_types.authtypecode IS NULL + }); + + $dbh->do(q{ + ALTER TABLE auth_subfield_structure + ADD CONSTRAINT auth_subfield_structure_ibfk_1 FOREIGN KEY (authtypecode) REFERENCES auth_types(authtypecode) ON DELETE CASCADE ON UPDATE CASCADE + }); + + print "Upgrade to $DBversion done (Bug 8480 - Add foreign key on auth_subfield_structure.authtypecode)\n"; + SetVersion($DBversion); +} + + # DEVELOPER PROCESS, search for anything to execute in the db_update directory # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. --