@@ -, +, @@ --- installer/data/mysql/atomicupdate/bug_31626.pl | 14 +++++++++----- installer/data/mysql/kohastructure.sql | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) --- a/installer/data/mysql/atomicupdate/bug_31626.pl +++ a/installer/data/mysql/atomicupdate/bug_31626.pl @@ -6,10 +6,14 @@ return { up => sub { my ($args) = @_; my ($dbh, $out) = @$args{qw(dbh out)}; - $dbh->do(q{ - ALTER TABLE message_queue - ADD COLUMN letter_id INT(11) NULL DEFAULT NULL AFTER message_id, - ADD CONSTRAINT letter_fk FOREIGN KEY (letter_id) REFERENCES letter(id) ON DELETE SET NULL ON UPDATE CASCADE - }); + unless ( column_exists( 'message_queue', 'letter_id' ) ) { + $dbh->do(q{ + ALTER TABLE message_queue + ADD COLUMN `letter_id` int(11) DEFAULT NULL COMMENT 'Foreign key to the letters table' AFTER message_id, + ADD CONSTRAINT letter_fk FOREIGN KEY (letter_id) REFERENCES letter(id) ON DELETE SET NULL ON UPDATE CASCADE + }); + + say $out "Added 'letter_id' column to 'message_queue' table"; + } }, }; --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -3847,7 +3847,7 @@ DROP TABLE IF EXISTS `message_queue`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `message_queue` ( `message_id` int(11) NOT NULL AUTO_INCREMENT, - `letter_id` int(11) DEFAULT NULL, + `letter_id` int(11) DEFAULT NULL COMMENT 'Foreign key to the letters table', `borrowernumber` int(11) DEFAULT NULL, `subject` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, `content` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, --