summaryrefslogtreecommitdiffstats
path: root/db/migrate
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-09-19 15:32:52 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-09-19 15:32:52 +0000
commit16e09bfd774487d7b21e1b939f9b0321ad3a850a (patch)
treef1952dff78c37929699621a06a1de69adf3fda2c /db/migrate
parent9e7bce6a94626b4f96133bddc508192f2dfaff4f (diff)
downloadredmine-16e09bfd774487d7b21e1b939f9b0321ad3a850a.tar.gz
redmine-16e09bfd774487d7b21e1b939f9b0321ad3a850a.zip
Adds watch/unwatch functionality at forum topic level (#1912).
Users who create/reply a topic are automatically added as watchers but are now able to unwatch the topic. git-svn-id: http://redmine.rubyforge.org/svn/trunk@1878 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/098_set_topic_authors_as_watchers.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/db/migrate/098_set_topic_authors_as_watchers.rb b/db/migrate/098_set_topic_authors_as_watchers.rb
new file mode 100644
index 000000000..5bc41fb38
--- /dev/null
+++ b/db/migrate/098_set_topic_authors_as_watchers.rb
@@ -0,0 +1,14 @@
+class SetTopicAuthorsAsWatchers < ActiveRecord::Migration
+ def self.up
+ # Sets active users who created/replied a topic as watchers of the topic
+ # so that the new watch functionality at topic level doesn't affect notifications behaviour
+ Message.connection.execute("INSERT INTO watchers (watchable_type, watchable_id, user_id)" +
+ " SELECT DISTINCT 'Message', COALESCE(messages.parent_id, messages.id), messages.author_id FROM messages, users" +
+ " WHERE messages.author_id = users.id AND users.status = 1")
+ end
+
+ def self.down
+ # Removes all message watchers
+ Watcher.delete_all("watchable_type = 'Message'")
+ end
+end