Mercurial > hg > soundsoftware-site
view db/migrate/098_set_topic_authors_as_watchers.rb @ 1517:dffacf8a6908 redmine-2.5
Update to Redmine SVN revision 13367 on 2.5-stable branch
author | Chris Cannam |
---|---|
date | Tue, 09 Sep 2014 09:29:00 +0100 |
parents | 513646585e45 |
children |
line wrap: on
line source
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 #{Watcher.table_name} (watchable_type, watchable_id, user_id)" + " SELECT DISTINCT 'Message', COALESCE(m.parent_id, m.id), m.author_id" + " FROM #{Message.table_name} m, #{User.table_name} u" + " WHERE m.author_id = u.id AND u.status = 1") end def self.down # Removes all message watchers Watcher.delete_all("watchable_type = 'Message'") end end