aboutsummaryrefslogtreecommitdiffstats
path: root/db/migrate/065_add_comments_to_user_track.rb
blob: 50d1f9d5d1cf31990d2c17b9b707c30d114d9a8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class AddCommentsToUserTrack < ActiveRecord::Migration
    def self.up
        TrackThing.update_all "track_query = replace(track_query, 'variety:sent ', '') where track_type in ('public_body_updates', 'user_updates')"
        track_things = TrackThing.find(:all, :conditions => [ "track_type = 'user_updates'" ])
        for track_thing in track_things
            track_thing.track_query = track_thing.track_query.gsub(/^requested_by:([^\s]+)$/, "requested_by:\\1 OR commented_by:\\1")
            track_thing.save!
        end
    end

    def self.down
      # TODO: forget it
    end
end