20180609104432_migrate_web_push_subscriptions2.rb 459 B

1234567891011121314151617
  1. class MigrateWebPushSubscriptions2 < ActiveRecord::Migration[5.2]
  2. disable_ddl_transaction!
  3. def up
  4. Web::PushSubscription.where(user_id: nil).select(:id).includes(:session_activation).find_each do |subscription|
  5. if subscription.session_activation.nil?
  6. subscription.delete
  7. else
  8. subscription.update_attribute(:user_id, subscription.session_activation.user_id)
  9. end
  10. end
  11. end
  12. def down
  13. # Nothing to do
  14. end
  15. end