diff --git a/comment_notify.install b/comment_notify.install
index fe18281..e202553 100644
--- a/comment_notify.install
+++ b/comment_notify.install
@@ -5,6 +5,30 @@
  */
 
 /**
+ * Implements hook_enable().
+ */
+function comment_notify_enable() {
+  // Create entries for existing comments.
+  $comments_select = db_select('comment', 'c');
+  $comments_select->join('users', 'u', 'c.uid = u.uid');
+  // Look for comments that have no rows in comment_notify.
+  $comments_select->join('comment_notify', 'cn', 'c.cid = cn.cid');
+  $comments_select->condition('cn.cid', NULL);
+  $comments_select->addField('c', 'cid');
+  $comments_select->addExpression('0', 'notify');
+  // Mix in a random string to all values.
+  $salt = uniqid(mt_rand(), TRUE);
+  if (db_driver() == 'pgsql') {
+    $comments_select->addExpression("MD5(:salt || c.mail || COALESCE(u.mail, u.init) || c.uid || c.name || c.nid || c.hostname || c.cid)", 'notify_hash', array(':salt' => $salt));
+  }
+  else {
+    $comments_select->addExpression("MD5(CONCAT(:salt, c.mail, COALESCE(u.mail, u.init), c.uid, c.name, c.nid, c.hostname, c.cid))", 'notify_hash', array(':salt' => $salt));
+  }
+
+  db_insert('comment_notify')->from($comments_select)->execute();
+}
+
+/**
  * Implements hook_install().
  */
 function comment_notify_install() {
