annotate db/migrate/098_set_topic_authors_as_watchers.rb @ 890:02c2efb96216
feature_20
Close obsolete branch feature_20
author |
Chris Cannam |
date |
Fri, 18 Feb 2011 19:46:11 +0000 |
parents |
513646585e45 |
children |
|
rev |
line source |
Chris@0
|
1 class SetTopicAuthorsAsWatchers < ActiveRecord::Migration
|
Chris@0
|
2 def self.up
|
Chris@0
|
3 # Sets active users who created/replied a topic as watchers of the topic
|
Chris@0
|
4 # so that the new watch functionality at topic level doesn't affect notifications behaviour
|
Chris@0
|
5 Message.connection.execute("INSERT INTO #{Watcher.table_name} (watchable_type, watchable_id, user_id)" +
|
Chris@0
|
6 " SELECT DISTINCT 'Message', COALESCE(m.parent_id, m.id), m.author_id" +
|
Chris@0
|
7 " FROM #{Message.table_name} m, #{User.table_name} u" +
|
Chris@0
|
8 " WHERE m.author_id = u.id AND u.status = 1")
|
Chris@0
|
9 end
|
Chris@0
|
10
|
Chris@0
|
11 def self.down
|
Chris@0
|
12 # Removes all message watchers
|
Chris@0
|
13 Watcher.delete_all("watchable_type = 'Message'")
|
Chris@0
|
14 end
|
Chris@0
|
15 end
|