This repository has been archived on 2024-06-09. You can view files and clone it, but cannot push or open issues/pull-requests.
2023-07-12 09:47:08 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-06-09 13:33:04 +02:00
|
|
|
class MigrateWebPushSubscriptions2 < ActiveRecord::Migration[5.2]
|
|
|
|
disable_ddl_transaction!
|
|
|
|
|
|
|
|
def up
|
|
|
|
Web::PushSubscription.where(user_id: nil).select(:id).includes(:session_activation).find_each do |subscription|
|
|
|
|
if subscription.session_activation.nil?
|
|
|
|
subscription.delete
|
|
|
|
else
|
|
|
|
subscription.update_attribute(:user_id, subscription.session_activation.user_id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
# Nothing to do
|
|
|
|
end
|
|
|
|
end
|