From 8248e4a64230870ccfa8d009918cda8b36142890 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sat, 6 Feb 2010 12:34:16 +0000
Subject: - Add workaround for MySQL bug
 [http://bugs.mysql.com/bug.php?id=46293] (#1486474)

---
 SQL/mysql.update.sql | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

(limited to 'SQL/mysql.update.sql')

diff --git a/SQL/mysql.update.sql b/SQL/mysql.update.sql
index 17301ab05..5ad03d4f6 100644
--- a/SQL/mysql.update.sql
+++ b/SQL/mysql.update.sql
@@ -57,3 +57,24 @@ ALTER TABLE `session`
 
 ALTER TABLE `contacts`
     ADD INDEX `user_contacts_index` (`user_id`,`email`);
+
+-- Updates from version 0.3.1
+
+/* MySQL bug workaround: http://bugs.mysql.com/bug.php?id=46293 */
+/*!40014 SET FOREIGN_KEY_CHECKS=0; */
+
+ALTER TABLE `messages` DROP FOREIGN KEY `user_id_fk_messages`;
+ALTER TABLE `cache` DROP FOREIGN KEY `user_id_fk_cache`;
+ALTER TABLE `contacts` DROP FOREIGN KEY `user_id_fk_contacts`;
+ALTER TABLE `identities` DROP FOREIGN KEY `user_id_fk_identities`;
+
+ALTER TABLE `messages` ADD CONSTRAINT `user_id_fk_messages` FOREIGN KEY (`user_id`)
+ REFERENCES `users`(`user_id`) /*!40008 ON DELETE CASCADE ON UPDATE CASCADE */;
+ALTER TABLE `cache` ADD CONSTRAINT `user_id_fk_cache` FOREIGN KEY (`user_id`)
+ REFERENCES `users`(`user_id`) /*!40008 ON DELETE CASCADE ON UPDATE CASCADE */;
+ALTER TABLE `contacts` ADD CONSTRAINT `user_id_fk_contacts` FOREIGN KEY (`user_id`)
+ REFERENCES `users`(`user_id`) /*!40008 ON DELETE CASCADE ON UPDATE CASCADE */;
+ALTER TABLE `identities` ADD CONSTRAINT `user_id_fk_identities` FOREIGN KEY (`user_id`)
+ REFERENCES `users`(`user_id`) /*!40008 ON DELETE CASCADE ON UPDATE CASCADE */;
+
+/*!40014 SET FOREIGN_KEY_CHECKS=1; */
-- 
cgit v1.2.3

