The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

19 lines
748 B

  1. # frozen_string_literal: true
  2. class RemoveInvalidWebPushSubscription < ActiveRecord::Migration[5.2]
  3. disable_ddl_transaction!
  4. def up
  5. invalid_web_push_subscriptions = Web::PushSubscription.where(endpoint: '')
  6. .or(Web::PushSubscription.where(key_p256dh: ''))
  7. .or(Web::PushSubscription.where(key_auth: ''))
  8. .preload(:session_activation)
  9. invalid_web_push_subscriptions.find_each do |web_push_subscription|
  10. web_push_subscription.session_activation&.update!(web_push_subscription_id: nil)
  11. web_push_subscription.destroy!
  12. end
  13. end
  14. def down; end
  15. end