From 0e2bffd5e8766cbed9ab324e25538abbc31d82c0 Mon Sep 17 00:00:00 2001 From: Andrew Moore Date: Fri, 20 Jun 2008 14:58:42 -0500 Subject: [PATCH] bug: 2176 - database fix I had the create table statements in the wrong order, so they would not apply cleanly. This is an update to database version 091, and does not take a new number. Signed-off-by: Joshua Ferraro --- installer/data/mysql/updatedatabase.pl | 48 +++++++++++++------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 1e75e9a2f2..8fff5cdd14 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -1675,33 +1675,9 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { $DBversion = "3.00.00.091"; if (C4::Context->preference("Version") < TransformToNum($DBversion)) { - $dbh->do(<<'END_SQL'); -CREATE TABLE `message_queue` ( - `message_id` int(11) NOT NULL auto_increment, - `borrowernumber` int(11) NOT NULL, - `subject` text, - `content` text, - `message_transport_type` varchar(20) NOT NULL, - `status` enum('sent','pending','failed','deleted') NOT NULL default 'pending', - `time_queued` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - KEY `message_id` (`message_id`), - KEY `borrowernumber` (`borrowernumber`), - KEY `message_transport_type` (`message_transport_type`), - CONSTRAINT `messageq_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `messageq_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE RESTRICT ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 -END_SQL - $dbh->do(<<'END_SQL'); ALTER TABLE borrowers ADD `smsalertnumber` varchar(50) default NULL -END_SQL - - $dbh->do(<<'END_SQL'); -CREATE TABLE `message_transport_types` ( - `message_transport_type` varchar(20) NOT NULL, - PRIMARY KEY (`message_transport_type`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; END_SQL $dbh->do(<<'END_SQL'); @@ -1712,6 +1688,13 @@ CREATE TABLE `message_attributes` ( PRIMARY KEY (`message_attribute_id`), UNIQUE KEY `message_name` (`message_name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 +END_SQL + + $dbh->do(<<'END_SQL'); +CREATE TABLE `message_transport_types` ( + `message_transport_type` varchar(20) NOT NULL, + PRIMARY KEY (`message_transport_type`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; END_SQL $dbh->do(<<'END_SQL'); @@ -1754,6 +1737,23 @@ CREATE TABLE `borrower_message_transport_preferences` ( CONSTRAINT `borrower_message_transport_preferences_ibfk_1` FOREIGN KEY (`borrower_message_preference_id`) REFERENCES `borrower_message_preferences` (`borrower_message_preference_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `borrower_message_transport_preferences_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 +END_SQL + + $dbh->do(<<'END_SQL'); +CREATE TABLE `message_queue` ( + `message_id` int(11) NOT NULL auto_increment, + `borrowernumber` int(11) NOT NULL, + `subject` text, + `content` text, + `message_transport_type` varchar(20) NOT NULL, + `status` enum('sent','pending','failed','deleted') NOT NULL default 'pending', + `time_queued` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + KEY `message_id` (`message_id`), + KEY `borrowernumber` (`borrowernumber`), + KEY `message_transport_type` (`message_transport_type`), + CONSTRAINT `messageq_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `messageq_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE RESTRICT ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 END_SQL $dbh->do(<<'END_SQL'); -- 2.39.5