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.

20150113211532_populate_email_addresses.rb 504B

1234567891011121314
  1. class PopulateEmailAddresses < ActiveRecord::Migration[4.2]
  2. def self.up
  3. t = EmailAddress.connection.quoted_true
  4. n = EmailAddress.connection.quoted_date(Time.now)
  5. sql = "INSERT INTO #{EmailAddress.table_name} (user_id, address, is_default, notify, created_on, updated_on)" +
  6. " SELECT id, mail, #{t}, #{t}, '#{n}', '#{n}' FROM #{User.table_name} WHERE type = 'User' ORDER BY id"
  7. EmailAddress.connection.execute(sql)
  8. end
  9. def self.down
  10. EmailAddress.delete_all
  11. end
  12. end