~cytrogen/masto-fe

ref: cc4560d95bae267a8f9281f9f559f8a08b87bd85 masto-fe/db/migrate/20180609104432_migrate_web_push_subscriptions2.rb -rw-r--r-- 490 bytes
cc4560d9 — Claire Change “privacy and reach” settings so that unchecking boxes always increase privacy and checking them always increase reach (#26508) 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

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