You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

098_set_topic_authors_as_watchers.rb 760B

123456789101112131415
  1. class SetTopicAuthorsAsWatchers < ActiveRecord::Migration[4.2]
  2. def self.up
  3. # Sets active users who created/replied a topic as watchers of the topic
  4. # so that the new watch functionality at topic level doesn't affect notifications behaviour
  5. Message.connection.execute("INSERT INTO #{Watcher.table_name} (watchable_type, watchable_id, user_id)" +
  6. " SELECT DISTINCT 'Message', COALESCE(m.parent_id, m.id), m.author_id" +
  7. " FROM #{Message.table_name} m, #{User.table_name} u" +
  8. " WHERE m.author_id = u.id AND u.status = 1")
  9. end
  10. def self.down
  11. # Removes all message watchers
  12. Watcher.where("watchable_type = 'Message'").delete_all
  13. end
  14. end