From f62edc3e834dabc386c5a8af3d2666235842e979 Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 10 Mar 2012 19:07:02 +0000 Subject: [PATCH] add FKs for comments --- ext/comment/main.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ext/comment/main.php b/ext/comment/main.php index dbb35a8a..1cbf888a 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -84,7 +84,7 @@ class CommentList extends Extension { INDEX (owner_ip), INDEX (posted), FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, - FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE + FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT "); $config->set_int("ext_comments_version", 3); } @@ -109,6 +109,12 @@ class CommentList extends Extension { $config->set_int("ext_comments_version", 2); } + if($config->get_int("ext_comments_version") == 2) { + $config->set_int("ext_comments_version", 3); + $database->Execute("ALTER TABLE comments ADD CONSTRAINT foreign_comments_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE"); + $database->Execute("ALTER TABLE comments ADD CONSTRAINT foreign_comments_owner_id FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT"); + } + // FIXME: add foreign keys, bump to v3 } }