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.

20100129193813_update_mail_notification_values.rb 869B

12345678910111213141516171819202122232425
  1. # Patch the data from a boolean change.
  2. class UpdateMailNotificationValues < ActiveRecord::Migration
  3. def self.up
  4. User.record_timestamps = false
  5. User.all.each do |u|
  6. u.mail_notification = if u.mail_notification =~ /\A(1|t)\z/
  7. # User set for all email (t is for sqlite)
  8. 'all'
  9. else
  10. # User wants to recieve notifications on specific projects?
  11. if u.memberships.count(:conditions => {:mail_notification => true}) > 0
  12. 'selected'
  13. else
  14. 'only_my_events'
  15. end
  16. end
  17. u.save!
  18. end
  19. User.record_timestamps = true
  20. end
  21. def self.down
  22. # No-op
  23. end
  24. end