Appease the dog overlords
This commit is contained in:
parent
93d4af3f0d
commit
a04b290067
|
@ -34,7 +34,7 @@ class Inbox < ApplicationRecord
|
|||
"frontend.push_notifications.inbox.title",
|
||||
user: question.author_is_anonymous ? user.profile.display_name : question.author.profile.safe_name
|
||||
),
|
||||
body: question.content,
|
||||
body: question.content
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module User::PushNotificationMethods
|
||||
def push_notification(app, resource)
|
||||
raise ArgumentError("Resource must respond to `as_push_notification`") unless resource.respond_to? :as_push_notification
|
||||
|
|
|
@ -18,7 +18,7 @@ class QuestionWorker
|
|||
next if MuteRule.where(user: f).any? { |rule| rule.applies_to? question }
|
||||
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)
|
||||
end
|
||||
rescue StandardError => e
|
||||
|
|
|
@ -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
|
||||
# added to your project!
|
||||
|
@ -33,15 +35,13 @@ class AddRpush < ActiveRecord::Migration[5.0]
|
|||
|
||||
def self.down
|
||||
migrations.reverse.each do |m|
|
||||
begin
|
||||
m.down
|
||||
rescue ActiveRecord::StatementInvalid => e
|
||||
p e
|
||||
end
|
||||
Rails.logger.debug e
|
||||
end
|
||||
end
|
||||
|
||||
class CreateRapnsNotifications < ActiveRecord::Migration[5.0]
|
||||
class AddRpush < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
create_table :rapns_notifications do |t|
|
||||
t.integer :badge, null: true
|
||||
|
@ -60,19 +60,17 @@ class AddRpush < ActiveRecord::Migration[5.0]
|
|||
t.timestamps
|
||||
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
|
||||
|
||||
def self.down
|
||||
if index_name_exists?(:rapns_notifications, 'index_rapns_notifications_multi')
|
||||
remove_index :rapns_notifications, name: 'index_rapns_notifications_multi'
|
||||
end
|
||||
remove_index :rapns_notifications, name: "index_rapns_notifications_multi" if index_name_exists?(:rapns_notifications, "index_rapns_notifications_multi")
|
||||
|
||||
drop_table :rapns_notifications
|
||||
end
|
||||
end
|
||||
|
||||
class CreateRapnsFeedback < ActiveRecord::Migration[5.0]
|
||||
class AddRpush < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
create_table :rapns_feedback do |t|
|
||||
t.string :device_token, null: false, limit: 64
|
||||
|
@ -84,15 +82,13 @@ class AddRpush < ActiveRecord::Migration[5.0]
|
|||
end
|
||||
|
||||
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
|
||||
end
|
||||
remove_index :rapns_feedback, name: :index_rapns_feedback_on_device_token if index_name_exists?(:rapns_feedback, :index_rapns_feedback_on_device_token)
|
||||
|
||||
drop_table :rapns_feedback
|
||||
end
|
||||
end
|
||||
|
||||
class AddAlertIsJsonToRapnsNotifications < ActiveRecord::Migration[5.0]
|
||||
class AddRpush < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
add_column :rapns_notifications, :alert_is_json, :boolean, null: true, default: false
|
||||
end
|
||||
|
@ -102,7 +98,7 @@ class AddRpush < ActiveRecord::Migration[5.0]
|
|||
end
|
||||
end
|
||||
|
||||
class AddAppToRapns < ActiveRecord::Migration[5.0]
|
||||
class AddRpush < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
add_column :rapns_notifications, :app, :string, null: true
|
||||
add_column :rapns_feedback, :app, :string, null: true
|
||||
|
@ -114,7 +110,7 @@ class AddRpush < ActiveRecord::Migration[5.0]
|
|||
end
|
||||
end
|
||||
|
||||
class CreateRapnsApps < ActiveRecord::Migration[5.0]
|
||||
class AddRpush < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
create_table :rapns_apps do |t|
|
||||
t.string :key, null: false
|
||||
|
@ -131,15 +127,15 @@ class AddRpush < ActiveRecord::Migration[5.0]
|
|||
end
|
||||
end
|
||||
|
||||
class AddGcm < ActiveRecord::Migration[5.0]
|
||||
class AddRpush < ActiveRecord::Migration[5.0]
|
||||
module Rapns
|
||||
class App < ActiveRecord::Base
|
||||
self.table_name = 'rapns_apps'
|
||||
class App < ApplicationRecord
|
||||
self.table_name = "rapns_apps"
|
||||
end
|
||||
|
||||
class Notification < ActiveRecord::Base
|
||||
class Notification < ApplicationRecord
|
||||
belongs_to :app
|
||||
self.table_name = 'rapns_notifications'
|
||||
self.table_name = "rapns_notifications"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -147,8 +143,8 @@ class AddRpush < ActiveRecord::Migration[5.0]
|
|||
add_column :rapns_notifications, :type, :string, null: true
|
||||
add_column :rapns_apps, :type, :string, null: true
|
||||
|
||||
AddGcm::Rapns::Notification.update_all type: 'Rapns::Apns::Notification'
|
||||
AddGcm::Rapns::App.update_all type: 'Rapns::Apns::App'
|
||||
AddGcm::Rapns::Notification.update_all type: "Rapns::Apns::Notification"
|
||||
AddGcm::Rapns::App.update_all type: "Rapns::Apns::App"
|
||||
|
||||
change_column :rapns_notifications, :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_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_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, :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, :app_id, :integer, null: true
|
||||
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"
|
||||
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
|
||||
|
||||
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_apps, :type
|
||||
|
@ -204,7 +200,7 @@ class AddRpush < ActiveRecord::Migration[5.0]
|
|||
change_column :rapns_apps, :certificate, :text, null: false
|
||||
|
||||
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_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)
|
||||
end
|
||||
|
||||
if index_name_exists?(:rapns_notifications, :index_rapns_notifications_multi)
|
||||
remove_index :rapns_notifications, name: :index_rapns_notifications_multi
|
||||
end
|
||||
remove_index :rapns_notifications, name: :index_rapns_notifications_multi if index_name_exists?(:rapns_notifications, :index_rapns_notifications_multi)
|
||||
|
||||
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
|
||||
|
||||
class AddWpns < ActiveRecord::Migration[5.0]
|
||||
class AddRpush < ActiveRecord::Migration[5.0]
|
||||
module Rapns
|
||||
class Notification < ActiveRecord::Base
|
||||
self.table_name = 'rapns_notifications'
|
||||
class Notification < ApplicationRecord
|
||||
self.table_name = "rapns_notifications"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -247,15 +241,15 @@ class AddRpush < ActiveRecord::Migration[5.0]
|
|||
end
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
class AddAdm < ActiveRecord::Migration[5.0]
|
||||
class AddRpush < ActiveRecord::Migration[5.0]
|
||||
module Rapns
|
||||
class Notification < ActiveRecord::Base
|
||||
self.table_name = 'rapns_notifications'
|
||||
class Notification < ApplicationRecord
|
||||
self.table_name = "rapns_notifications"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -267,7 +261,7 @@ class AddRpush < ActiveRecord::Migration[5.0]
|
|||
end
|
||||
|
||||
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_secret
|
||||
|
@ -276,14 +270,14 @@ class AddRpush < ActiveRecord::Migration[5.0]
|
|||
end
|
||||
end
|
||||
|
||||
class RenameRapnsToRpush < ActiveRecord::Migration[5.0]
|
||||
class AddRpush < ActiveRecord::Migration[5.0]
|
||||
module Rpush
|
||||
class App < ActiveRecord::Base
|
||||
self.table_name = 'rpush_apps'
|
||||
class App < ApplicationRecord
|
||||
self.table_name = "rpush_apps"
|
||||
end
|
||||
|
||||
class Notification < ActiveRecord::Base
|
||||
self.table_name = 'rpush_notifications'
|
||||
class Notification < ApplicationRecord
|
||||
self.table_name = "rpush_notifications"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -296,43 +290,35 @@ class AddRpush < ActiveRecord::Migration[5.0]
|
|||
rename_table :rapns_apps, :rpush_apps
|
||||
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
|
||||
end
|
||||
rename_index :rpush_notifications, :index_rapns_notifications_multi, :index_rpush_notifications_multi if index_name_exists?(:rpush_notifications, :index_rapns_notifications_multi)
|
||||
|
||||
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
|
||||
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)
|
||||
|
||||
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::Adm::Notification', 'Rpush::Adm::Notification')
|
||||
update_type(RenameRapnsToRpush::Rpush::Notification, 'Rapns::Wpns::Notification', 'Rpush::Wpns::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::Adm::Notification", "Rpush::Adm::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::Gcm::App', 'Rpush::Gcm::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::Apns::App", "Rpush::Apns::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::Wpns::App", "Rpush::Wpns::App")
|
||||
end
|
||||
|
||||
def self.down
|
||||
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::Adm::Notification', 'Rapns::Adm::Notification')
|
||||
update_type(RenameRapnsToRpush::Rpush::Notification, 'Rpush::Wpns::Notification', 'Rapns::Wpns::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::Adm::Notification", "Rapns::Adm::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::Gcm::App', 'Rapns::Gcm::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::Apns::App", "Rapns::Apns::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::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
|
||||
end
|
||||
rename_index :rpush_notifications, :index_rpush_notifications_multi, :index_rapns_notifications_multi if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi)
|
||||
|
||||
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_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_table :rpush_notifications, :rapns_notifications
|
||||
rename_table :rpush_apps, :rapns_apps
|
||||
|
@ -340,7 +326,7 @@ class AddRpush < ActiveRecord::Migration[5.0]
|
|||
end
|
||||
end
|
||||
|
||||
class AddFailAfterToRpushNotifications < ActiveRecord::Migration[5.0]
|
||||
class AddRpush < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
add_column :rpush_notifications, :fail_after, :timestamp, null: true
|
||||
end
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Rpush200Updates < ActiveRecord::Migration[5.0]
|
||||
module Rpush
|
||||
class App < ActiveRecord::Base
|
||||
self.table_name = 'rpush_apps'
|
||||
class App < ApplicationRecord
|
||||
self.table_name = "rpush_apps"
|
||||
end
|
||||
|
||||
class Notification < ActiveRecord::Base
|
||||
self.table_name = 'rpush_notifications'
|
||||
class Notification < ApplicationRecord
|
||||
self.table_name = "rpush_notifications"
|
||||
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, :priority, :integer, null: true
|
||||
|
||||
if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi)
|
||||
remove_index :rpush_notifications, name: :index_rpush_notifications_multi
|
||||
end
|
||||
remove_index :rpush_notifications, name: :index_rpush_notifications_multi if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi)
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
change_column :rpush_feedback, :app_id, :integer
|
||||
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::Notification, "Rpush::#{service}::Notification", "Rpush::Client::ActiveRecord::#{service}::Notification")
|
||||
end
|
||||
end
|
||||
|
||||
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::Notification, "Rpush::Client::ActiveRecord::#{service}::Notification", "Rpush::#{service}::Notification")
|
||||
end
|
||||
|
@ -46,22 +46,20 @@ class Rpush200Updates < ActiveRecord::Migration[5.0]
|
|||
change_column :rpush_feedback, :app_id, :string
|
||||
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
|
||||
end
|
||||
remove_index :rpush_notifications, name: :index_rpush_notifications_multi if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi)
|
||||
|
||||
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, :processing
|
||||
end
|
||||
|
||||
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
|
||||
ActiveRecord::Base.configurations.configs_for(env_name: env).first.configuration_hash[:adapter]
|
||||
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
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Rpush210Updates < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
add_column :rpush_notifications, :url_args, :text, null: true
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Rpush260Updates < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Rpush270Updates < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
change_column :rpush_notifications, :alert, :text
|
||||
|
@ -9,4 +11,3 @@ class Rpush270Updates < ActiveRecord::Migration[5.0]
|
|||
remove_column :rpush_notifications, :notification
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Rpush300Updates < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
add_column :rpush_notifications, :mutable_content, :boolean, default: false
|
||||
|
@ -6,6 +8,6 @@ class Rpush300Updates < ActiveRecord::Migration[5.0]
|
|||
|
||||
def self.down
|
||||
remove_column :rpush_notifications, :mutable_content
|
||||
change_column :rpush_notifications, :sound, :string, default: 'default'
|
||||
change_column :rpush_notifications, :sound, :string, default: "default"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Rpush301Updates < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
change_column_null :rpush_notifications, :mutable_content, false
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Rpush310AddPushy < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
add_column :rpush_notifications, :external_device_id, :string, null: true
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Rpush311Updates < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
change_table :rpush_notifications do |t|
|
||||
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.remove_index name: "index_rpush_notifications_multi"
|
||||
t.index %i[delivered failed processing deliver_after created_at], name: "index_rpush_notifications_multi", where: "NOT delivered AND NOT failed"
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
change_table :rpush_notifications do |t|
|
||||
t.remove_index name: 'index_rpush_notifications_multi'
|
||||
t.index [:delivered, :failed], name: 'index_rpush_notifications_multi', where: 'NOT delivered AND NOT failed'
|
||||
t.remove_index name: "index_rpush_notifications_multi"
|
||||
t.index %i[delivered failed], name: "index_rpush_notifications_multi", where: "NOT delivered AND NOT failed"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Rpush320AddApnsP8 < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
add_column :rpush_apps, :apn_key, :string, null: true
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Rpush324Updates < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
change_column :rpush_apps, :apn_key, :text, null: true
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Rpush330Updates < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
add_column :rpush_notifications, :thread_id, :string, null: true
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Rpush331Updates < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
change_column :rpush_notifications, :device_token, :string, null: true
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Rpush410Updates < ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"]
|
||||
def self.up
|
||||
add_column :rpush_notifications, :dry_run, :boolean, null: false, default: false
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Rpush411Updates < ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"]
|
||||
def self.up
|
||||
add_column :rpush_apps, :feedback_enabled, :boolean, default: true
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Rpush420Updates < ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"]
|
||||
def self.up
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateWebPushSubscriptions < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
create_table :web_push_subscriptions do |t|
|
||||
|
|
Loading…
Reference in New Issue