chris@37: # Patch the data from a boolean change. chris@37: class UpdateMailNotificationValues < ActiveRecord::Migration chris@37: def self.up chris@37: User.update_all("mail_notification = 'all'", "mail_notification IN ('1', 't')") chris@37: User.update_all("mail_notification = 'selected'", "EXISTS (SELECT 1 FROM #{Member.table_name} WHERE #{Member.table_name}.mail_notification = #{connection.quoted_true} AND #{Member.table_name}.user_id = #{User.table_name}.id)") chris@37: User.update_all("mail_notification = 'only_my_events'", "mail_notification NOT IN ('all', 'selected')") chris@37: end chris@37: chris@37: def self.down chris@37: # No-op chris@37: end chris@37: end