Appease the dog overlords

This commit is contained in:
Karina Kwiatek 2022-09-11 23:20:10 +02:00
parent 93d4af3f0d
commit a04b290067
20 changed files with 116 additions and 103 deletions

View File

@ -34,7 +34,7 @@ class Inbox < ApplicationRecord
"frontend.push_notifications.inbox.title", "frontend.push_notifications.inbox.title",
user: question.author_is_anonymous ? user.profile.display_name : question.author.profile.safe_name user: question.author_is_anonymous ? user.profile.display_name : question.author.profile.safe_name
), ),
body: question.content, body: question.content
} }
end end
end end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module User::PushNotificationMethods module User::PushNotificationMethods
def push_notification(app, resource) def push_notification(app, resource)
raise ArgumentError("Resource must respond to `as_push_notification`") unless resource.respond_to? :as_push_notification raise ArgumentError("Resource must respond to `as_push_notification`") unless resource.respond_to? :as_push_notification

View File

@ -18,7 +18,7 @@ class QuestionWorker
next if MuteRule.where(user: f).any? { |rule| rule.applies_to? question } next if MuteRule.where(user: f).any? { |rule| rule.applies_to? question }
next if user.muting?(question.user) next if user.muting?(question.user)
inbox = Inbox.create(user_id: f.id, question_id: question_id, new: true) inbox = Inbox.create(user_id: f.id, question_id:, new: true)
f.push_notification(webpush_app, inbox) f.push_notification(webpush_app, inbox)
end end
rescue StandardError => e rescue StandardError => e

View File

@ -1,4 +1,6 @@
# NOTE TO THE CURIOUS. # frozen_string_literal: true
# NOTE: TO THE CURIOUS.
# #
# Congratulations on being a diligent developer and vetting the migrations # Congratulations on being a diligent developer and vetting the migrations
# added to your project! # added to your project!
@ -33,15 +35,13 @@ class AddRpush < ActiveRecord::Migration[5.0]
def self.down def self.down
migrations.reverse.each do |m| migrations.reverse.each do |m|
begin m.down
m.down rescue ActiveRecord::StatementInvalid => e
rescue ActiveRecord::StatementInvalid => e Rails.logger.debug e
p e
end
end end
end end
class CreateRapnsNotifications < ActiveRecord::Migration[5.0] class AddRpush < ActiveRecord::Migration[5.0]
def self.up def self.up
create_table :rapns_notifications do |t| create_table :rapns_notifications do |t|
t.integer :badge, null: true t.integer :badge, null: true
@ -60,19 +60,17 @@ class AddRpush < ActiveRecord::Migration[5.0]
t.timestamps t.timestamps
end end
add_index :rapns_notifications, [:delivered, :failed, :deliver_after], name: 'index_rapns_notifications_multi' add_index :rapns_notifications, %i[delivered failed deliver_after], name: "index_rapns_notifications_multi"
end end
def self.down def self.down
if index_name_exists?(:rapns_notifications, 'index_rapns_notifications_multi') remove_index :rapns_notifications, name: "index_rapns_notifications_multi" if index_name_exists?(:rapns_notifications, "index_rapns_notifications_multi")
remove_index :rapns_notifications, name: 'index_rapns_notifications_multi'
end
drop_table :rapns_notifications drop_table :rapns_notifications
end end
end end
class CreateRapnsFeedback < ActiveRecord::Migration[5.0] class AddRpush < ActiveRecord::Migration[5.0]
def self.up def self.up
create_table :rapns_feedback do |t| create_table :rapns_feedback do |t|
t.string :device_token, null: false, limit: 64 t.string :device_token, null: false, limit: 64
@ -84,15 +82,13 @@ class AddRpush < ActiveRecord::Migration[5.0]
end end
def self.down def self.down
if index_name_exists?(:rapns_feedback, :index_rapns_feedback_on_device_token) remove_index :rapns_feedback, name: :index_rapns_feedback_on_device_token if index_name_exists?(:rapns_feedback, :index_rapns_feedback_on_device_token)
remove_index :rapns_feedback, name: :index_rapns_feedback_on_device_token
end
drop_table :rapns_feedback drop_table :rapns_feedback
end end
end end
class AddAlertIsJsonToRapnsNotifications < ActiveRecord::Migration[5.0] class AddRpush < ActiveRecord::Migration[5.0]
def self.up def self.up
add_column :rapns_notifications, :alert_is_json, :boolean, null: true, default: false add_column :rapns_notifications, :alert_is_json, :boolean, null: true, default: false
end end
@ -102,7 +98,7 @@ class AddRpush < ActiveRecord::Migration[5.0]
end end
end end
class AddAppToRapns < ActiveRecord::Migration[5.0] class AddRpush < ActiveRecord::Migration[5.0]
def self.up def self.up
add_column :rapns_notifications, :app, :string, null: true add_column :rapns_notifications, :app, :string, null: true
add_column :rapns_feedback, :app, :string, null: true add_column :rapns_feedback, :app, :string, null: true
@ -114,7 +110,7 @@ class AddRpush < ActiveRecord::Migration[5.0]
end end
end end
class CreateRapnsApps < ActiveRecord::Migration[5.0] class AddRpush < ActiveRecord::Migration[5.0]
def self.up def self.up
create_table :rapns_apps do |t| create_table :rapns_apps do |t|
t.string :key, null: false t.string :key, null: false
@ -131,15 +127,15 @@ class AddRpush < ActiveRecord::Migration[5.0]
end end
end end
class AddGcm < ActiveRecord::Migration[5.0] class AddRpush < ActiveRecord::Migration[5.0]
module Rapns module Rapns
class App < ActiveRecord::Base class App < ApplicationRecord
self.table_name = 'rapns_apps' self.table_name = "rapns_apps"
end end
class Notification < ActiveRecord::Base class Notification < ApplicationRecord
belongs_to :app belongs_to :app
self.table_name = 'rapns_notifications' self.table_name = "rapns_notifications"
end end
end end
@ -147,8 +143,8 @@ class AddRpush < ActiveRecord::Migration[5.0]
add_column :rapns_notifications, :type, :string, null: true add_column :rapns_notifications, :type, :string, null: true
add_column :rapns_apps, :type, :string, null: true add_column :rapns_apps, :type, :string, null: true
AddGcm::Rapns::Notification.update_all type: 'Rapns::Apns::Notification' AddGcm::Rapns::Notification.update_all type: "Rapns::Apns::Notification"
AddGcm::Rapns::App.update_all type: 'Rapns::Apns::App' AddGcm::Rapns::App.update_all type: "Rapns::Apns::App"
change_column :rapns_notifications, :type, :string, null: false change_column :rapns_notifications, :type, :string, null: false
change_column :rapns_apps, :type, :string, null: false change_column :rapns_apps, :type, :string, null: false
@ -158,7 +154,7 @@ class AddRpush < ActiveRecord::Migration[5.0]
change_column :rapns_apps, :certificate, :text, null: true, default: nil change_column :rapns_apps, :certificate, :text, null: true, default: nil
change_column :rapns_notifications, :error_description, :text, null: true, default: nil change_column :rapns_notifications, :error_description, :text, null: true, default: nil
change_column :rapns_notifications, :sound, :string, default: 'default' change_column :rapns_notifications, :sound, :string, default: "default"
rename_column :rapns_notifications, :attributes_for_device, :data rename_column :rapns_notifications, :attributes_for_device, :data
rename_column :rapns_apps, :key, :name rename_column :rapns_apps, :key, :name
@ -168,7 +164,7 @@ class AddRpush < ActiveRecord::Migration[5.0]
add_column :rapns_notifications, :collapse_key, :string, null: true add_column :rapns_notifications, :collapse_key, :string, null: true
add_column :rapns_notifications, :delay_while_idle, :boolean, null: false, default: false add_column :rapns_notifications, :delay_while_idle, :boolean, null: false, default: false
reg_ids_type = ActiveRecord::Base.connection.adapter_name.include?('Mysql') ? :mediumtext : :text reg_ids_type = ActiveRecord::Base.connection.adapter_name.include?("Mysql") ? :mediumtext : :text
add_column :rapns_notifications, :registration_ids, reg_ids_type, null: true add_column :rapns_notifications, :registration_ids, reg_ids_type, null: true
add_column :rapns_notifications, :app_id, :integer, null: true add_column :rapns_notifications, :app_id, :integer, null: true
add_column :rapns_notifications, :retries, :integer, null: true, default: 0 add_column :rapns_notifications, :retries, :integer, null: true, default: 0
@ -189,11 +185,11 @@ class AddRpush < ActiveRecord::Migration[5.0]
remove_index :rapns_notifications, name: "index_rapns_notifications_on_delivered_failed_deliver_after" remove_index :rapns_notifications, name: "index_rapns_notifications_on_delivered_failed_deliver_after"
end end
add_index :rapns_notifications, [:app_id, :delivered, :failed, :deliver_after], name: "index_rapns_notifications_multi" add_index :rapns_notifications, %i[app_id delivered failed deliver_after], name: "index_rapns_notifications_multi"
end end
def self.down def self.down
AddGcm::Rapns::Notification.where(type: 'Rapns::Gcm::Notification').delete_all AddGcm::Rapns::Notification.where(type: "Rapns::Gcm::Notification").delete_all
remove_column :rapns_notifications, :type remove_column :rapns_notifications, :type
remove_column :rapns_apps, :type remove_column :rapns_apps, :type
@ -204,7 +200,7 @@ class AddRpush < ActiveRecord::Migration[5.0]
change_column :rapns_apps, :certificate, :text, null: false change_column :rapns_apps, :certificate, :text, null: false
change_column :rapns_notifications, :error_description, :string, null: true, default: nil change_column :rapns_notifications, :error_description, :string, null: true, default: nil
change_column :rapns_notifications, :sound, :string, default: '1.aiff' change_column :rapns_notifications, :sound, :string, default: "1.aiff"
rename_column :rapns_notifications, :data, :attributes_for_device rename_column :rapns_notifications, :data, :attributes_for_device
rename_column :rapns_apps, :name, :key rename_column :rapns_apps, :name, :key
@ -225,20 +221,18 @@ class AddRpush < ActiveRecord::Migration[5.0]
AddGcm::Rapns::Notification.where(app_id: app.id).update_all(app: app.key) AddGcm::Rapns::Notification.where(app_id: app.id).update_all(app: app.key)
end end
if index_name_exists?(:rapns_notifications, :index_rapns_notifications_multi) remove_index :rapns_notifications, name: :index_rapns_notifications_multi if index_name_exists?(:rapns_notifications, :index_rapns_notifications_multi)
remove_index :rapns_notifications, name: :index_rapns_notifications_multi
end
remove_column :rapns_notifications, :app_id remove_column :rapns_notifications, :app_id
add_index :rapns_notifications, [:delivered, :failed, :deliver_after], name: :index_rapns_notifications_multi add_index :rapns_notifications, %i[delivered failed deliver_after], name: :index_rapns_notifications_multi
end end
end end
class AddWpns < ActiveRecord::Migration[5.0] class AddRpush < ActiveRecord::Migration[5.0]
module Rapns module Rapns
class Notification < ActiveRecord::Base class Notification < ApplicationRecord
self.table_name = 'rapns_notifications' self.table_name = "rapns_notifications"
end end
end end
@ -247,15 +241,15 @@ class AddRpush < ActiveRecord::Migration[5.0]
end end
def self.down def self.down
AddWpns::Rapns::Notification.where(type: 'Rapns::Wpns::Notification').delete_all AddWpns::Rapns::Notification.where(type: "Rapns::Wpns::Notification").delete_all
remove_column :rapns_notifications, :uri remove_column :rapns_notifications, :uri
end end
end end
class AddAdm < ActiveRecord::Migration[5.0] class AddRpush < ActiveRecord::Migration[5.0]
module Rapns module Rapns
class Notification < ActiveRecord::Base class Notification < ApplicationRecord
self.table_name = 'rapns_notifications' self.table_name = "rapns_notifications"
end end
end end
@ -267,7 +261,7 @@ class AddRpush < ActiveRecord::Migration[5.0]
end end
def self.down def self.down
AddAdm::Rapns::Notification.where(type: 'Rapns::Adm::Notification').delete_all AddAdm::Rapns::Notification.where(type: "Rapns::Adm::Notification").delete_all
remove_column :rapns_apps, :client_id remove_column :rapns_apps, :client_id
remove_column :rapns_apps, :client_secret remove_column :rapns_apps, :client_secret
@ -276,14 +270,14 @@ class AddRpush < ActiveRecord::Migration[5.0]
end end
end end
class RenameRapnsToRpush < ActiveRecord::Migration[5.0] class AddRpush < ActiveRecord::Migration[5.0]
module Rpush module Rpush
class App < ActiveRecord::Base class App < ApplicationRecord
self.table_name = 'rpush_apps' self.table_name = "rpush_apps"
end end
class Notification < ActiveRecord::Base class Notification < ApplicationRecord
self.table_name = 'rpush_notifications' self.table_name = "rpush_notifications"
end end
end end
@ -296,43 +290,35 @@ class AddRpush < ActiveRecord::Migration[5.0]
rename_table :rapns_apps, :rpush_apps rename_table :rapns_apps, :rpush_apps
rename_table :rapns_feedback, :rpush_feedback rename_table :rapns_feedback, :rpush_feedback
if index_name_exists?(:rpush_notifications, :index_rapns_notifications_multi) rename_index :rpush_notifications, :index_rapns_notifications_multi, :index_rpush_notifications_multi if index_name_exists?(:rpush_notifications, :index_rapns_notifications_multi)
rename_index :rpush_notifications, :index_rapns_notifications_multi, :index_rpush_notifications_multi
end
if index_name_exists?(:rpush_feedback, :index_rapns_feedback_on_device_token) rename_index :rpush_feedback, :index_rapns_feedback_on_device_token, :index_rpush_feedback_on_device_token if index_name_exists?(:rpush_feedback, :index_rapns_feedback_on_device_token)
rename_index :rpush_feedback, :index_rapns_feedback_on_device_token, :index_rpush_feedback_on_device_token
end
update_type(RenameRapnsToRpush::Rpush::Notification, 'Rapns::Apns::Notification', 'Rpush::Apns::Notification') update_type(RenameRapnsToRpush::Rpush::Notification, "Rapns::Apns::Notification", "Rpush::Apns::Notification")
update_type(RenameRapnsToRpush::Rpush::Notification, 'Rapns::Gcm::Notification', 'Rpush::Gcm::Notification') update_type(RenameRapnsToRpush::Rpush::Notification, "Rapns::Gcm::Notification", "Rpush::Gcm::Notification")
update_type(RenameRapnsToRpush::Rpush::Notification, 'Rapns::Adm::Notification', 'Rpush::Adm::Notification') update_type(RenameRapnsToRpush::Rpush::Notification, "Rapns::Adm::Notification", "Rpush::Adm::Notification")
update_type(RenameRapnsToRpush::Rpush::Notification, 'Rapns::Wpns::Notification', 'Rpush::Wpns::Notification') update_type(RenameRapnsToRpush::Rpush::Notification, "Rapns::Wpns::Notification", "Rpush::Wpns::Notification")
update_type(RenameRapnsToRpush::Rpush::App, 'Rapns::Apns::App', 'Rpush::Apns::App') update_type(RenameRapnsToRpush::Rpush::App, "Rapns::Apns::App", "Rpush::Apns::App")
update_type(RenameRapnsToRpush::Rpush::App, 'Rapns::Gcm::App', 'Rpush::Gcm::App') update_type(RenameRapnsToRpush::Rpush::App, "Rapns::Gcm::App", "Rpush::Gcm::App")
update_type(RenameRapnsToRpush::Rpush::App, 'Rapns::Adm::App', 'Rpush::Adm::App') update_type(RenameRapnsToRpush::Rpush::App, "Rapns::Adm::App", "Rpush::Adm::App")
update_type(RenameRapnsToRpush::Rpush::App, 'Rapns::Wpns::App', 'Rpush::Wpns::App') update_type(RenameRapnsToRpush::Rpush::App, "Rapns::Wpns::App", "Rpush::Wpns::App")
end end
def self.down def self.down
update_type(RenameRapnsToRpush::Rpush::Notification, 'Rpush::Apns::Notification', 'Rapns::Apns::Notification') update_type(RenameRapnsToRpush::Rpush::Notification, "Rpush::Apns::Notification", "Rapns::Apns::Notification")
update_type(RenameRapnsToRpush::Rpush::Notification, 'Rpush::Gcm::Notification', 'Rapns::Gcm::Notification') update_type(RenameRapnsToRpush::Rpush::Notification, "Rpush::Gcm::Notification", "Rapns::Gcm::Notification")
update_type(RenameRapnsToRpush::Rpush::Notification, 'Rpush::Adm::Notification', 'Rapns::Adm::Notification') update_type(RenameRapnsToRpush::Rpush::Notification, "Rpush::Adm::Notification", "Rapns::Adm::Notification")
update_type(RenameRapnsToRpush::Rpush::Notification, 'Rpush::Wpns::Notification', 'Rapns::Wpns::Notification') update_type(RenameRapnsToRpush::Rpush::Notification, "Rpush::Wpns::Notification", "Rapns::Wpns::Notification")
update_type(RenameRapnsToRpush::Rpush::App, 'Rpush::Apns::App', 'Rapns::Apns::App') update_type(RenameRapnsToRpush::Rpush::App, "Rpush::Apns::App", "Rapns::Apns::App")
update_type(RenameRapnsToRpush::Rpush::App, 'Rpush::Gcm::App', 'Rapns::Gcm::App') update_type(RenameRapnsToRpush::Rpush::App, "Rpush::Gcm::App", "Rapns::Gcm::App")
update_type(RenameRapnsToRpush::Rpush::App, 'Rpush::Adm::App', 'Rapns::Adm::App') update_type(RenameRapnsToRpush::Rpush::App, "Rpush::Adm::App", "Rapns::Adm::App")
update_type(RenameRapnsToRpush::Rpush::App, 'Rpush::Wpns::App', 'Rapns::Wpns::App') update_type(RenameRapnsToRpush::Rpush::App, "Rpush::Wpns::App", "Rapns::Wpns::App")
if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi) rename_index :rpush_notifications, :index_rpush_notifications_multi, :index_rapns_notifications_multi if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi)
rename_index :rpush_notifications, :index_rpush_notifications_multi, :index_rapns_notifications_multi
end
if index_name_exists?(:rpush_feedback, :index_rpush_feedback_on_device_token) rename_index :rpush_feedback, :index_rpush_feedback_on_device_token, :index_rapns_feedback_on_device_token if index_name_exists?(:rpush_feedback, :index_rpush_feedback_on_device_token)
rename_index :rpush_feedback, :index_rpush_feedback_on_device_token, :index_rapns_feedback_on_device_token
end
rename_table :rpush_notifications, :rapns_notifications rename_table :rpush_notifications, :rapns_notifications
rename_table :rpush_apps, :rapns_apps rename_table :rpush_apps, :rapns_apps
@ -340,7 +326,7 @@ class AddRpush < ActiveRecord::Migration[5.0]
end end
end end
class AddFailAfterToRpushNotifications < ActiveRecord::Migration[5.0] class AddRpush < ActiveRecord::Migration[5.0]
def self.up def self.up
add_column :rpush_notifications, :fail_after, :timestamp, null: true add_column :rpush_notifications, :fail_after, :timestamp, null: true
end end

View File

@ -1,11 +1,13 @@
# frozen_string_literal: true
class Rpush200Updates < ActiveRecord::Migration[5.0] class Rpush200Updates < ActiveRecord::Migration[5.0]
module Rpush module Rpush
class App < ActiveRecord::Base class App < ApplicationRecord
self.table_name = 'rpush_apps' self.table_name = "rpush_apps"
end end
class Notification < ActiveRecord::Base class Notification < ApplicationRecord
self.table_name = 'rpush_notifications' self.table_name = "rpush_notifications"
end end
end end
@ -17,28 +19,26 @@ class Rpush200Updates < ActiveRecord::Migration[5.0]
add_column :rpush_notifications, :processing, :boolean, null: false, default: false add_column :rpush_notifications, :processing, :boolean, null: false, default: false
add_column :rpush_notifications, :priority, :integer, null: true add_column :rpush_notifications, :priority, :integer, null: true
if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi) remove_index :rpush_notifications, name: :index_rpush_notifications_multi if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi)
remove_index :rpush_notifications, name: :index_rpush_notifications_multi
end
add_index :rpush_notifications, [:delivered, :failed], name: 'index_rpush_notifications_multi', where: 'NOT delivered AND NOT failed' add_index :rpush_notifications, %i[delivered failed], name: "index_rpush_notifications_multi", where: "NOT delivered AND NOT failed"
rename_column :rpush_feedback, :app, :app_id rename_column :rpush_feedback, :app, :app_id
if postgresql? if postgresql?
execute('ALTER TABLE rpush_feedback ALTER COLUMN app_id TYPE integer USING (trim(app_id)::integer)') execute("ALTER TABLE rpush_feedback ALTER COLUMN app_id TYPE integer USING (trim(app_id)::integer)")
else else
change_column :rpush_feedback, :app_id, :integer change_column :rpush_feedback, :app_id, :integer
end end
[:Apns, :Gcm, :Wpns, :Adm].each do |service| %i[Apns Gcm Wpns Adm].each do |service|
update_type(Rpush200Updates::Rpush::App, "Rpush::#{service}::App", "Rpush::Client::ActiveRecord::#{service}::App") update_type(Rpush200Updates::Rpush::App, "Rpush::#{service}::App", "Rpush::Client::ActiveRecord::#{service}::App")
update_type(Rpush200Updates::Rpush::Notification, "Rpush::#{service}::Notification", "Rpush::Client::ActiveRecord::#{service}::Notification") update_type(Rpush200Updates::Rpush::Notification, "Rpush::#{service}::Notification", "Rpush::Client::ActiveRecord::#{service}::Notification")
end end
end end
def self.down def self.down
[:Apns, :Gcm, :Wpns, :Adm].each do |service| %i[Apns Gcm Wpns Adm].each do |service|
update_type(Rpush200Updates::Rpush::App, "Rpush::Client::ActiveRecord::#{service}::App", "Rpush::#{service}::App") update_type(Rpush200Updates::Rpush::App, "Rpush::Client::ActiveRecord::#{service}::App", "Rpush::#{service}::App")
update_type(Rpush200Updates::Rpush::Notification, "Rpush::Client::ActiveRecord::#{service}::Notification", "Rpush::#{service}::Notification") update_type(Rpush200Updates::Rpush::Notification, "Rpush::Client::ActiveRecord::#{service}::Notification", "Rpush::#{service}::Notification")
end end
@ -46,22 +46,20 @@ class Rpush200Updates < ActiveRecord::Migration[5.0]
change_column :rpush_feedback, :app_id, :string change_column :rpush_feedback, :app_id, :string
rename_column :rpush_feedback, :app_id, :app rename_column :rpush_feedback, :app_id, :app
if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi) remove_index :rpush_notifications, name: :index_rpush_notifications_multi if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi)
remove_index :rpush_notifications, name: :index_rpush_notifications_multi
end
add_index :rpush_notifications, [:app_id, :delivered, :failed, :deliver_after], name: 'index_rpush_notifications_multi' add_index :rpush_notifications, %i[app_id delivered failed deliver_after], name: "index_rpush_notifications_multi"
remove_column :rpush_notifications, :priority remove_column :rpush_notifications, :priority
remove_column :rpush_notifications, :processing remove_column :rpush_notifications, :processing
end end
def self.adapter_name def self.adapter_name
env = (defined?(Rails) && Rails.env) ? Rails.env : 'development' env = defined?(Rails) && Rails.env ? Rails.env : "development"
if ActiveRecord::VERSION::MAJOR > 6 if ActiveRecord::VERSION::MAJOR > 6
ActiveRecord::Base.configurations.configs_for(env_name: env).first.configuration_hash[:adapter] ActiveRecord::Base.configurations.configs_for(env_name: env).first.configuration_hash[:adapter]
else else
Hash[ActiveRecord::Base.configurations[env].map { |k,v| [k.to_sym,v] }][:adapter] ActiveRecord::Base.configurations[env].to_h { |k, v| [k.to_sym, v] }[:adapter]
end end
end end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Rpush210Updates < ActiveRecord::Migration[5.0] class Rpush210Updates < ActiveRecord::Migration[5.0]
def self.up def self.up
add_column :rpush_notifications, :url_args, :text, null: true add_column :rpush_notifications, :url_args, :text, null: true

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Rpush260Updates < ActiveRecord::Migration[5.0] class Rpush260Updates < ActiveRecord::Migration[5.0]
def self.up def self.up
add_column :rpush_notifications, :content_available, :boolean, default: false add_column :rpush_notifications, :content_available, :boolean, default: false
@ -7,4 +9,3 @@ class Rpush260Updates < ActiveRecord::Migration[5.0]
remove_column :rpush_notifications, :content_available remove_column :rpush_notifications, :content_available
end end
end end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Rpush270Updates < ActiveRecord::Migration[5.0] class Rpush270Updates < ActiveRecord::Migration[5.0]
def self.up def self.up
change_column :rpush_notifications, :alert, :text change_column :rpush_notifications, :alert, :text
@ -9,4 +11,3 @@ class Rpush270Updates < ActiveRecord::Migration[5.0]
remove_column :rpush_notifications, :notification remove_column :rpush_notifications, :notification
end end
end end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Rpush300Updates < ActiveRecord::Migration[5.0] class Rpush300Updates < ActiveRecord::Migration[5.0]
def self.up def self.up
add_column :rpush_notifications, :mutable_content, :boolean, default: false add_column :rpush_notifications, :mutable_content, :boolean, default: false
@ -6,6 +8,6 @@ class Rpush300Updates < ActiveRecord::Migration[5.0]
def self.down def self.down
remove_column :rpush_notifications, :mutable_content remove_column :rpush_notifications, :mutable_content
change_column :rpush_notifications, :sound, :string, default: 'default' change_column :rpush_notifications, :sound, :string, default: "default"
end end
end end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Rpush301Updates < ActiveRecord::Migration[5.0] class Rpush301Updates < ActiveRecord::Migration[5.0]
def self.up def self.up
change_column_null :rpush_notifications, :mutable_content, false change_column_null :rpush_notifications, :mutable_content, false

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Rpush310AddPushy < ActiveRecord::Migration[5.0] class Rpush310AddPushy < ActiveRecord::Migration[5.0]
def self.up def self.up
add_column :rpush_notifications, :external_device_id, :string, null: true add_column :rpush_notifications, :external_device_id, :string, null: true

View File

@ -1,15 +1,17 @@
# frozen_string_literal: true
class Rpush311Updates < ActiveRecord::Migration[5.0] class Rpush311Updates < ActiveRecord::Migration[5.0]
def self.up def self.up
change_table :rpush_notifications do |t| change_table :rpush_notifications do |t|
t.remove_index name: 'index_rpush_notifications_multi' t.remove_index name: "index_rpush_notifications_multi"
t.index [:delivered, :failed, :processing, :deliver_after, :created_at], name: 'index_rpush_notifications_multi', where: 'NOT delivered AND NOT failed' t.index %i[delivered failed processing deliver_after created_at], name: "index_rpush_notifications_multi", where: "NOT delivered AND NOT failed"
end end
end end
def self.down def self.down
change_table :rpush_notifications do |t| change_table :rpush_notifications do |t|
t.remove_index name: 'index_rpush_notifications_multi' t.remove_index name: "index_rpush_notifications_multi"
t.index [:delivered, :failed], name: 'index_rpush_notifications_multi', where: 'NOT delivered AND NOT failed' t.index %i[delivered failed], name: "index_rpush_notifications_multi", where: "NOT delivered AND NOT failed"
end end
end end
end end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Rpush320AddApnsP8 < ActiveRecord::Migration[5.0] class Rpush320AddApnsP8 < ActiveRecord::Migration[5.0]
def self.up def self.up
add_column :rpush_apps, :apn_key, :string, null: true add_column :rpush_apps, :apn_key, :string, null: true

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Rpush324Updates < ActiveRecord::Migration[5.0] class Rpush324Updates < ActiveRecord::Migration[5.0]
def self.up def self.up
change_column :rpush_apps, :apn_key, :text, null: true change_column :rpush_apps, :apn_key, :text, null: true

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Rpush330Updates < ActiveRecord::Migration[5.0] class Rpush330Updates < ActiveRecord::Migration[5.0]
def self.up def self.up
add_column :rpush_notifications, :thread_id, :string, null: true add_column :rpush_notifications, :thread_id, :string, null: true

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Rpush331Updates < ActiveRecord::Migration[5.0] class Rpush331Updates < ActiveRecord::Migration[5.0]
def self.up def self.up
change_column :rpush_notifications, :device_token, :string, null: true change_column :rpush_notifications, :device_token, :string, null: true

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Rpush410Updates < ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"] class Rpush410Updates < ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"]
def self.up def self.up
add_column :rpush_notifications, :dry_run, :boolean, null: false, default: false add_column :rpush_notifications, :dry_run, :boolean, null: false, default: false

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Rpush411Updates < ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"] class Rpush411Updates < ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"]
def self.up def self.up
add_column :rpush_apps, :feedback_enabled, :boolean, default: true add_column :rpush_apps, :feedback_enabled, :boolean, default: true

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Rpush420Updates < ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"] class Rpush420Updates < ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"]
def self.up def self.up
add_column :rpush_notifications, :sound_is_json, :boolean, null: true, default: false add_column :rpush_notifications, :sound_is_json, :boolean, null: true, default: false
@ -7,4 +9,3 @@ class Rpush420Updates < ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}
remove_column :rpush_notifications, :sound_is_json remove_column :rpush_notifications, :sound_is_json
end end
end end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateWebPushSubscriptions < ActiveRecord::Migration[6.1] class CreateWebPushSubscriptions < ActiveRecord::Migration[6.1]
def change def change
create_table :web_push_subscriptions do |t| create_table :web_push_subscriptions do |t|