1
0

20180609104432_migrate_web_push_subscriptions2.rb 490 B

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