Bug 27534: Add missing ON UPDATE/DELETE clause to message_transport_type_fk

Bug 9016 (3.15.00.039) added message_transport_type_fk but the ON DELETE
CASCADE ON UPDATE CASCADE clause was missing from the updatedatabase
entry.
If we are upgrading from an old version, 20.06.00.058 will fail on
updating the message_transport_type, with
"Cannot delete or update a parent row: a foreign key constraint fails".

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2021-01-27 09:43:02 +01:00
parent 63e3311b10
commit 57a15eb474
1 changed files with 11 additions and 1 deletions

View File

@ -8305,7 +8305,7 @@ if ( CheckVersion($DBversion) ) {
} );
$dbh->do( q{
ALTER TABLE letter ADD CONSTRAINT message_transport_type_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types(message_transport_type);
ALTER TABLE letter ADD CONSTRAINT message_transport_type_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types(message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE
} );
$dbh->do( q{
@ -23173,6 +23173,16 @@ if( CheckVersion( $DBversion ) ) {
$DBversion = '20.06.00.058';
if( CheckVersion( $DBversion ) ) {
# Adding the ON DELETE CASCASE ON UPDATE CASCADE, in case it's missing (from 9016 - 3.15.00.039)
$dbh->do( q{
ALTER TABLE letter DROP FOREIGN KEY message_transport_type_fk
} );
$dbh->do( q{
ALTER TABLE letter ADD CONSTRAINT message_transport_type_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types(message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE
} );
$dbh->do(q{
UPDATE message_transport_types SET message_transport_type = "itiva" WHERE message_transport_type = "phone"
});