Browse Source

Migrate old web push subscriptions to ensure deliveries (#7764)

pull/4/head
Eugen Rochko 4 years ago
committed by GitHub
parent
commit
18e1de6a16
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions
  1. +17
    -0
      db/migrate/20180609104432_migrate_web_push_subscriptions2.rb
  2. +1
    -1
      db/schema.rb

+ 17
- 0
db/migrate/20180609104432_migrate_web_push_subscriptions2.rb View File

@ -0,0 +1,17 @@
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

+ 1
- 1
db/schema.rb View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2018_05_28_141303) do
ActiveRecord::Schema.define(version: 2018_06_09_104432) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

Loading…
Cancel
Save