To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / .svn / pristine / 8c / 8c1df4d73d6e3117c24c3c76b9007e79ab4c6eb2.svn-base @ 1297:0a574315af3e
History | View | Annotate | Download (749 Bytes)
| 1 |
class SetTopicAuthorsAsWatchers < ActiveRecord::Migration |
|---|---|
| 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 |
|
| 11 |
def self.down |
| 12 |
# Removes all message watchers |
| 13 |
Watcher.delete_all("watchable_type = 'Message'")
|
| 14 |
end |
| 15 |
end |