rpush 1.0.0 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +12 -14
- data/bin/rpush +11 -2
- data/lib/generators/rpush_generator.rb +2 -0
- data/lib/generators/templates/add_adm.rb +5 -5
- data/lib/generators/templates/add_alert_is_json_to_rapns_notifications.rb +1 -1
- data/lib/generators/templates/add_app_to_rapns.rb +2 -2
- data/lib/generators/templates/add_fail_after_to_rpush_notifications.rb +1 -1
- data/lib/generators/templates/add_gcm.rb +32 -32
- data/lib/generators/templates/add_rpush.rb +67 -67
- data/lib/generators/templates/add_wpns.rb +2 -2
- data/lib/generators/templates/create_rapns_apps.rb +5 -5
- data/lib/generators/templates/create_rapns_feedback.rb +2 -2
- data/lib/generators/templates/create_rapns_notifications.rb +15 -15
- data/lib/generators/templates/rpush.rb +10 -7
- data/lib/generators/templates/rpush_2_0_0_updates.rb +23 -0
- data/lib/rpush.rb +4 -28
- data/lib/rpush/client/active_model.rb +21 -0
- data/lib/rpush/client/active_model/adm/app.rb +23 -0
- data/lib/rpush/client/active_model/adm/data_validator.rb +14 -0
- data/lib/rpush/client/active_model/adm/notification.rb +28 -0
- data/lib/rpush/client/active_model/apns/app.rb +37 -0
- data/lib/rpush/client/active_model/apns/binary_notification_validator.rb +16 -0
- data/lib/rpush/client/active_model/apns/device_token_format_validator.rb +14 -0
- data/lib/rpush/client/active_model/apns/notification.rb +90 -0
- data/lib/rpush/client/active_model/gcm/app.rb +19 -0
- data/lib/rpush/client/active_model/gcm/expiry_collapse_key_mutual_inclusion_validator.rb +14 -0
- data/lib/rpush/client/active_model/gcm/notification.rb +31 -0
- data/lib/rpush/client/active_model/notification.rb +26 -0
- data/lib/rpush/client/active_model/payload_data_size_validator.rb +13 -0
- data/lib/rpush/client/active_model/registration_ids_count_validator.rb +13 -0
- data/lib/rpush/client/active_model/wpns/app.rb +13 -0
- data/lib/rpush/client/active_model/wpns/notification.rb +17 -0
- data/lib/rpush/client/active_record.rb +19 -0
- data/lib/rpush/client/active_record/adm/app.rb +11 -0
- data/lib/rpush/client/active_record/adm/notification.rb +11 -0
- data/lib/rpush/client/active_record/apns/app.rb +11 -0
- data/lib/rpush/client/active_record/apns/feedback.rb +20 -0
- data/lib/rpush/client/active_record/apns/notification.rb +46 -0
- data/lib/rpush/client/active_record/app.rb +17 -0
- data/lib/rpush/client/active_record/gcm/app.rb +11 -0
- data/lib/rpush/client/active_record/gcm/notification.rb +11 -0
- data/lib/rpush/client/active_record/notification.rb +38 -0
- data/lib/rpush/client/active_record/wpns/app.rb +11 -0
- data/lib/rpush/client/active_record/wpns/notification.rb +11 -0
- data/lib/rpush/client/redis.rb +35 -0
- data/lib/rpush/client/redis/adm/app.rb +14 -0
- data/lib/rpush/client/redis/adm/notification.rb +11 -0
- data/lib/rpush/client/redis/apns/app.rb +11 -0
- data/lib/rpush/client/redis/apns/feedback.rb +20 -0
- data/lib/rpush/client/redis/apns/notification.rb +11 -0
- data/lib/rpush/client/redis/app.rb +22 -0
- data/lib/rpush/client/redis/gcm/app.rb +11 -0
- data/lib/rpush/client/redis/gcm/notification.rb +11 -0
- data/lib/rpush/client/redis/notification.rb +68 -0
- data/lib/rpush/client/redis/wpns/app.rb +11 -0
- data/lib/rpush/client/redis/wpns/notification.rb +11 -0
- data/lib/rpush/configuration.rb +27 -6
- data/lib/rpush/daemon.rb +36 -56
- data/lib/rpush/daemon/adm/delivery.rb +50 -52
- data/lib/rpush/daemon/apns.rb +6 -5
- data/lib/rpush/daemon/apns/delivery.rb +20 -44
- data/lib/rpush/daemon/apns/feedback_receiver.rb +11 -8
- data/lib/rpush/daemon/app_runner.rb +67 -60
- data/lib/rpush/daemon/batch.rb +54 -40
- data/lib/rpush/daemon/delivery.rb +13 -3
- data/lib/rpush/daemon/delivery_error.rb +10 -2
- data/lib/rpush/daemon/dispatcher/apns_tcp.rb +106 -0
- data/lib/rpush/daemon/dispatcher/http.rb +3 -3
- data/lib/rpush/daemon/dispatcher/tcp.rb +3 -3
- data/lib/rpush/daemon/dispatcher_loop.rb +15 -6
- data/lib/rpush/daemon/errors.rb +18 -0
- data/lib/rpush/daemon/feeder.rb +28 -39
- data/lib/rpush/daemon/gcm/delivery.rb +19 -20
- data/lib/rpush/daemon/interruptible_sleep.rb +26 -45
- data/lib/rpush/daemon/loggable.rb +2 -4
- data/lib/rpush/daemon/proc_title.rb +16 -0
- data/lib/rpush/daemon/queue_payload.rb +12 -0
- data/lib/rpush/daemon/reflectable.rb +3 -5
- data/lib/rpush/daemon/retry_header_parser.rb +6 -6
- data/lib/rpush/daemon/ring_buffer.rb +16 -0
- data/lib/rpush/daemon/service_config_methods.rb +23 -7
- data/lib/rpush/daemon/signal_handler.rb +51 -0
- data/lib/rpush/daemon/store/active_record.rb +71 -38
- data/lib/rpush/daemon/store/active_record/reconnectable.rb +15 -15
- data/lib/rpush/daemon/store/interface.rb +19 -0
- data/lib/rpush/daemon/store/redis.rb +149 -0
- data/lib/rpush/daemon/tcp_connection.rb +6 -11
- data/lib/rpush/daemon/wpns/delivery.rb +21 -30
- data/lib/rpush/deprecatable.rb +4 -3
- data/lib/rpush/deprecation.rb +7 -10
- data/lib/rpush/embed.rb +7 -2
- data/lib/rpush/logger.rb +11 -15
- data/lib/rpush/push.rb +0 -1
- data/lib/rpush/reflection.rb +6 -12
- data/lib/rpush/version.rb +1 -1
- data/lib/tasks/quality.rake +34 -0
- data/spec/.rubocop.yml +4 -0
- data/spec/functional/adm_spec.rb +3 -6
- data/spec/functional/apns_spec.rb +118 -24
- data/spec/functional/embed_spec.rb +22 -20
- data/spec/functional/gcm_spec.rb +4 -7
- data/spec/functional/new_app_spec.rb +61 -0
- data/spec/functional/retry_spec.rb +46 -0
- data/spec/functional/wpns_spec.rb +3 -6
- data/spec/functional_spec_helper.rb +26 -0
- data/spec/integration/rpush_spec.rb +13 -0
- data/spec/integration/support/gcm_success_response.json +1 -0
- data/spec/spec_helper.rb +60 -0
- data/spec/support/active_record_setup.rb +48 -0
- data/{config → spec/support/config}/database.yml +0 -0
- data/spec/support/install.sh +43 -7
- data/spec/support/simplecov_helper.rb +9 -5
- data/spec/support/simplecov_quality_formatter.rb +10 -6
- data/spec/unit/apns_feedback_spec.rb +3 -3
- data/spec/unit/{adm → client/active_record/adm}/app_spec.rb +3 -3
- data/spec/unit/{adm → client/active_record/adm}/notification_spec.rb +5 -7
- data/spec/unit/client/active_record/apns/app_spec.rb +29 -0
- data/spec/unit/client/active_record/apns/feedback_spec.rb +9 -0
- data/spec/unit/client/active_record/apns/notification_spec.rb +231 -0
- data/spec/unit/client/active_record/app_spec.rb +30 -0
- data/spec/unit/client/active_record/gcm/app_spec.rb +4 -0
- data/spec/unit/{gcm → client/active_record/gcm}/notification_spec.rb +5 -7
- data/spec/unit/client/active_record/notification_spec.rb +15 -0
- data/spec/unit/client/active_record/wpns/app_spec.rb +4 -0
- data/spec/unit/client/active_record/wpns/notification_spec.rb +21 -0
- data/spec/unit/configuration_spec.rb +12 -5
- data/spec/unit/daemon/adm/delivery_spec.rb +57 -54
- data/spec/unit/daemon/apns/certificate_expired_error_spec.rb +3 -3
- data/spec/unit/daemon/apns/delivery_spec.rb +90 -83
- data/spec/unit/daemon/apns/feedback_receiver_spec.rb +24 -17
- data/spec/unit/daemon/app_runner_spec.rb +66 -123
- data/spec/unit/daemon/batch_spec.rb +52 -115
- data/spec/unit/daemon/delivery_spec.rb +15 -1
- data/spec/unit/daemon/dispatcher/http_spec.rb +3 -2
- data/spec/unit/daemon/dispatcher/tcp_spec.rb +10 -9
- data/spec/unit/daemon/dispatcher_loop_spec.rb +7 -12
- data/spec/unit/daemon/feeder_spec.rb +40 -39
- data/spec/unit/daemon/gcm/delivery_spec.rb +108 -89
- data/spec/unit/daemon/reflectable_spec.rb +2 -2
- data/spec/unit/daemon/retryable_error_spec.rb +1 -1
- data/spec/unit/daemon/service_config_methods_spec.rb +6 -3
- data/spec/unit/daemon/signal_handler_spec.rb +72 -0
- data/spec/unit/daemon/store/active_record/reconnectable_spec.rb +9 -9
- data/spec/unit/daemon/store/active_record_spec.rb +38 -47
- data/spec/unit/daemon/tcp_connection_spec.rb +22 -34
- data/spec/unit/daemon/too_many_requests_error_spec.rb +1 -1
- data/spec/unit/daemon/wpns/delivery_spec.rb +61 -50
- data/spec/unit/daemon_spec.rb +46 -81
- data/spec/unit/embed_spec.rb +4 -2
- data/spec/unit/logger_spec.rb +30 -40
- data/spec/unit/notification_shared.rb +9 -79
- data/spec/unit/push_spec.rb +3 -8
- data/spec/unit/reflection_spec.rb +25 -25
- data/spec/unit/rpush_spec.rb +1 -2
- data/spec/unit_spec_helper.rb +33 -88
- metadata +119 -67
- data/lib/rpush/TODO +0 -3
- data/lib/rpush/adm/app.rb +0 -15
- data/lib/rpush/adm/data_validator.rb +0 -11
- data/lib/rpush/adm/notification.rb +0 -29
- data/lib/rpush/apns/app.rb +0 -29
- data/lib/rpush/apns/binary_notification_validator.rb +0 -12
- data/lib/rpush/apns/device_token_format_validator.rb +0 -12
- data/lib/rpush/apns/feedback.rb +0 -16
- data/lib/rpush/apns/notification.rb +0 -84
- data/lib/rpush/app.rb +0 -18
- data/lib/rpush/daemon/apns/certificate_expired_error.rb +0 -20
- data/lib/rpush/daemon/apns/disconnection_error.rb +0 -20
- data/lib/rpush/gcm/app.rb +0 -11
- data/lib/rpush/gcm/expiry_collapse_key_mutual_inclusion_validator.rb +0 -11
- data/lib/rpush/gcm/notification.rb +0 -30
- data/lib/rpush/notification.rb +0 -69
- data/lib/rpush/notifier.rb +0 -52
- data/lib/rpush/payload_data_size_validator.rb +0 -10
- data/lib/rpush/railtie.rb +0 -11
- data/lib/rpush/registration_ids_count_validator.rb +0 -10
- data/lib/rpush/wpns/app.rb +0 -9
- data/lib/rpush/wpns/notification.rb +0 -26
- data/lib/tasks/cane.rake +0 -18
- data/lib/tasks/rpush.rake +0 -16
- data/spec/unit/apns/app_spec.rb +0 -29
- data/spec/unit/apns/feedback_spec.rb +0 -9
- data/spec/unit/apns/notification_spec.rb +0 -208
- data/spec/unit/app_spec.rb +0 -30
- data/spec/unit/daemon/apns/disconnection_error_spec.rb +0 -18
- data/spec/unit/daemon/interruptible_sleep_spec.rb +0 -68
- data/spec/unit/gcm/app_spec.rb +0 -4
- data/spec/unit/notification_spec.rb +0 -15
- data/spec/unit/notifier_spec.rb +0 -49
- data/spec/unit/wpns/app_spec.rb +0 -4
- data/spec/unit/wpns/notification_spec.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d5bf4a64ca72a0c58b62a78da3e4315d06601cc
|
4
|
+
data.tar.gz: 2472ea351a2cc76e46668951eeabcfaf43b94b1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e34c0d97f7a604e0cc47b9c2e3548055207d87cd7a09c0800632c123cc4d7f4f62c7dbc7d014fa302c797ae822e2df2ae788d50b9670c24b003dbe00e7af767
|
7
|
+
data.tar.gz: 39e8509bb7fcfc76cb0347d55b4eee1a74f2083248ea3c71ccfbfff5e08a4ca8a3cfe6d8f6d1b7f788955f8af8fea016c469e741a5306c0c547fef5afd031029
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## 2.0.0 (unreleased)
|
2
|
+
* Use APNs enhanced binary format version 2.
|
3
|
+
* Support running multiple Rpush processes when using ActiveRecord and Redis.
|
4
|
+
* APNs error detection is now performed asynchronously, 'check_for_errors' is therefore deprecated.
|
5
|
+
* Deprecated attributes_for_device accessors. Use data instead.
|
6
|
+
* Fix signal handling to work with Ruby 2.x. (#40).
|
7
|
+
* You no longer need to signal HUP after creating a new app, they will be loaded automatically for you.
|
8
|
+
* APNs notifications are now delivered in batches, greatly improving throughput.
|
9
|
+
* Signaling HUP now also causes Rpush to immediately check for new notifications.
|
10
|
+
* The 'wakeup' config option has been removed.
|
11
|
+
* The 'batch_storage_updates' config option has been deprecated, storage backends will now always batch updates where appropriate.
|
12
|
+
* The rpush process title updates with number of queued notifications and number of dispatchers.
|
13
|
+
|
1
14
|
## 1.0.0 (Feb 9, 2014)
|
2
15
|
* Renamed to Rpush (from Rapns). Version number reset to 1.0.0.
|
3
16
|
* Reduce default batch size to 100.
|
data/README.md
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
[![Build Status](https://secure.travis-ci.org/rpush/rpush.png?branch=master)](http://travis-ci.org/rpush/rpush)
|
2
2
|
[![Code Climate](https://codeclimate.com/github/rpush/rpush.png)](https://codeclimate.com/github/rpush/rpush)
|
3
|
-
[![Coverage
|
3
|
+
[![Code Coverage](https://codeclimate.com/github/rpush/rpush/coverage.png)](https://codeclimate.com/github/rpush/rpush)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/rpush.png)](http://badge.fury.io/rb/rpush)
|
5
5
|
|
6
|
-
<img src="https://raw.github.com/rpush/rpush/master/
|
6
|
+
<img src="https://raw.github.com/rpush/rpush/master/logo.png" align="right" width="200px" />
|
7
7
|
|
8
8
|
### Rpush. The push notification service for Ruby.
|
9
9
|
|
10
10
|
* Supports:
|
11
11
|
* **Apple Push Notification Service**
|
12
|
-
* **Google Cloud Messaging
|
13
|
-
* **Amazon
|
14
|
-
* **Windows Push Notification Service**.
|
12
|
+
* **Google Cloud Messaging**
|
13
|
+
* **Amazon Device Messaging**
|
14
|
+
* **Windows Phone Push Notification Service**.
|
15
15
|
* Seamless Rails (3, 4) integration.
|
16
16
|
* Scalable - choose the number of persistent connections for each app.
|
17
17
|
* Designed for uptime - signal -HUP to add, update apps.
|
18
18
|
* Run as a daemon or inside an [existing processs](https://github.com/rpush/rpush/wiki/Embedding-API).
|
19
19
|
* Use in a scheduler for low-workload deployments ([Push API](https://github.com/rpush/rpush/wiki/Push-API)).
|
20
20
|
* Hooks for fine-grained instrumentation and error handling ([Reflection API](https://github.com/rpush/rpush/wiki/Reflection-API)).
|
21
|
-
* Works with MRI, JRuby
|
21
|
+
* Works with MRI, JRuby and Rubinius.
|
22
22
|
|
23
23
|
|
24
24
|
### Getting Started
|
@@ -57,7 +57,7 @@ n = Rpush::Apns::Notification.new
|
|
57
57
|
n.app = Rpush::Apns::App.find_by_name("ios_app")
|
58
58
|
n.device_token = "..."
|
59
59
|
n.alert = "hi mom!"
|
60
|
-
n.
|
60
|
+
n.data = { foo: :bar }
|
61
61
|
n.save!
|
62
62
|
```
|
63
63
|
|
@@ -76,8 +76,8 @@ app.save!
|
|
76
76
|
```ruby
|
77
77
|
n = Rpush::Gcm::Notification.new
|
78
78
|
n.app = Rpush::Gcm::App.find_by_name("android_app")
|
79
|
-
n.registration_ids = ["..."]
|
80
|
-
n.data = {:
|
79
|
+
n.registration_ids = ["token", "..."]
|
80
|
+
n.data = { message: "hi mom!" }
|
81
81
|
n.save!
|
82
82
|
```
|
83
83
|
|
@@ -98,7 +98,7 @@ app.save!
|
|
98
98
|
n = Rpush::Adm::Notification.new
|
99
99
|
n.app = Rpush::Adm::App.find_by_name("kindle_app")
|
100
100
|
n.registration_ids = ["..."]
|
101
|
-
n.data = {:
|
101
|
+
n.data = { message: "hi mom!"}
|
102
102
|
n.collapse_key = "Optional consolidationKey"
|
103
103
|
n.save!
|
104
104
|
```
|
@@ -124,7 +124,7 @@ n.save!
|
|
124
124
|
|
125
125
|
### Starting Rpush
|
126
126
|
|
127
|
-
As a daemon:
|
127
|
+
As a daemon (recommended):
|
128
128
|
|
129
129
|
cd /path/to/rails/app
|
130
130
|
rpush <Rails environment> [options]
|
@@ -135,8 +135,6 @@ Inside an existing process (see [Embedding API](https://github.com/rpush/rpush/w
|
|
135
135
|
Rpush.embed
|
136
136
|
```
|
137
137
|
|
138
|
-
*Please note that only ever a single instance of Rpush should be running.*
|
139
|
-
|
140
138
|
In a scheduler (see [Push API](https://github.com/rpush/rpush/wiki/Push-API)):
|
141
139
|
|
142
140
|
```ruby
|
@@ -172,7 +170,7 @@ After updating you should run `rails g rpush` to check for any new migrations.
|
|
172
170
|
* [Silent failures might be dropped connections](https://github.com/rpush/rpush/wiki/Dropped-connections)
|
173
171
|
|
174
172
|
### Google Cloud Messaging
|
175
|
-
* [Notification Options](https://github.com/rpush/rpush/wiki
|
173
|
+
* [Notification Options](https://github.com/rpush/rpush/wiki/GCM-Notification-Options)
|
176
174
|
* [Canonical IDs](https://github.com/rpush/rpush/wiki/Canonical-IDs)
|
177
175
|
* [Delivery Failures & Retries](https://github.com/rpush/rpush/wiki/Delivery-Failures-&-Retries)
|
178
176
|
|
data/bin/rpush
CHANGED
@@ -16,8 +16,17 @@ options = ARGV.options do |opts|
|
|
16
16
|
opts.on('-p PATH', '--pid-file PATH', String, 'Path to write PID file. Relative to Rails root unless absolute.') { |path| config.pid_file = path }
|
17
17
|
opts.on('-b N', '--batch-size N', Integer, 'Storage backend notification batch size.') { |n| config.batch_size = n }
|
18
18
|
opts.on('-B', '--[no-]batch-storage-updates', 'Perform storage updates in batches.') { |v| config.batch_storage_updates = v }
|
19
|
-
opts.on('-v', '--version', 'Print the version.')
|
20
|
-
|
19
|
+
opts.on('-v', '--version', 'Print the version.') do
|
20
|
+
puts "rpush #{Rpush::VERSION}"
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
opts.on('-h', '--help', 'You\'re looking at it.') do
|
24
|
+
hidden_switches = %w(-e --no-error-checks)
|
25
|
+
puts opts.to_s.split("\n").delete_if do |line|
|
26
|
+
hidden_switches.any? { |s| line =~ /#{s}/ }
|
27
|
+
end.join("\n")
|
28
|
+
exit
|
29
|
+
end
|
21
30
|
end
|
22
31
|
|
23
32
|
if environment.nil? || environment =~ /^-/
|
@@ -20,8 +20,10 @@ class RpushGenerator < Rails::Generators::Base
|
|
20
20
|
add_rpush_migration('add_adm')
|
21
21
|
add_rpush_migration('rename_rapns_to_rpush')
|
22
22
|
add_rpush_migration('add_fail_after_to_rpush_notifications')
|
23
|
+
add_rpush_migration('add_processing_to_rpush_notifications')
|
23
24
|
else
|
24
25
|
add_rpush_migration('add_rpush')
|
26
|
+
add_rpush_migration('rpush_2_0_0_updates')
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
@@ -6,14 +6,14 @@ class AddAdm < ActiveRecord::Migration
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.up
|
9
|
-
add_column :rapns_apps, :client_id, :string, :
|
10
|
-
add_column :rapns_apps, :client_secret, :string, :
|
11
|
-
add_column :rapns_apps, :access_token, :string, :
|
12
|
-
add_column :rapns_apps, :access_token_expiration, :datetime, :
|
9
|
+
add_column :rapns_apps, :client_id, :string, null: true
|
10
|
+
add_column :rapns_apps, :client_secret, :string, null: true
|
11
|
+
add_column :rapns_apps, :access_token, :string, null: true
|
12
|
+
add_column :rapns_apps, :access_token_expiration, :datetime, null: true
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.down
|
16
|
-
AddAdm::Rapns::Notification.where(:
|
16
|
+
AddAdm::Rapns::Notification.where(type: 'Rapns::Adm::Notification').delete_all
|
17
17
|
|
18
18
|
remove_column :rapns_apps, :client_id
|
19
19
|
remove_column :rapns_apps, :client_secret
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class AddAlertIsJsonToRapnsNotifications < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
|
-
add_column :rapns_notifications, :alert_is_json, :boolean, :
|
3
|
+
add_column :rapns_notifications, :alert_is_json, :boolean, null: true, default: false
|
4
4
|
end
|
5
5
|
|
6
6
|
def self.down
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class AddAppToRapns < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
|
-
add_column :rapns_notifications, :app, :string, :
|
4
|
-
add_column :rapns_feedback, :app, :string, :
|
3
|
+
add_column :rapns_notifications, :app, :string, null: true
|
4
|
+
add_column :rapns_feedback, :app, :string, null: true
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.down
|
@@ -11,34 +11,34 @@ class AddGcm < ActiveRecord::Migration
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.up
|
14
|
-
add_column :rapns_notifications, :type, :string, :
|
15
|
-
add_column :rapns_apps, :type, :string, :
|
14
|
+
add_column :rapns_notifications, :type, :string, null: true
|
15
|
+
add_column :rapns_apps, :type, :string, null: true
|
16
16
|
|
17
|
-
AddGcm::Rapns::Notification.update_all :
|
18
|
-
AddGcm::Rapns::App.update_all :
|
17
|
+
AddGcm::Rapns::Notification.update_all type: 'Rapns::Apns::Notification'
|
18
|
+
AddGcm::Rapns::App.update_all type: 'Rapns::Apns::App'
|
19
19
|
|
20
|
-
change_column :rapns_notifications, :type, :string, :
|
21
|
-
change_column :rapns_apps, :type, :string, :
|
22
|
-
change_column :rapns_notifications, :device_token, :string, { :
|
23
|
-
change_column :rapns_notifications, :expiry, :integer, { :
|
24
|
-
change_column :rapns_apps, :environment, :string, :
|
25
|
-
change_column :rapns_apps, :certificate, :text, :
|
20
|
+
change_column :rapns_notifications, :type, :string, null: false
|
21
|
+
change_column :rapns_apps, :type, :string, null: false
|
22
|
+
change_column :rapns_notifications, :device_token, :string, { null: true, limit: 64 }
|
23
|
+
change_column :rapns_notifications, :expiry, :integer, { null: true, default: 1.day.to_i }
|
24
|
+
change_column :rapns_apps, :environment, :string, null: true
|
25
|
+
change_column :rapns_apps, :certificate, :text, null: true, default: nil
|
26
26
|
|
27
|
-
change_column :rapns_notifications, :error_description, :text, :
|
28
|
-
change_column :rapns_notifications, :sound, :string, :
|
27
|
+
change_column :rapns_notifications, :error_description, :text, null: true, default: nil
|
28
|
+
change_column :rapns_notifications, :sound, :string, default: 'default'
|
29
29
|
|
30
30
|
rename_column :rapns_notifications, :attributes_for_device, :data
|
31
31
|
rename_column :rapns_apps, :key, :name
|
32
32
|
|
33
|
-
add_column :rapns_apps, :auth_key, :string, :
|
33
|
+
add_column :rapns_apps, :auth_key, :string, null: true
|
34
34
|
|
35
|
-
add_column :rapns_notifications, :collapse_key, :string, :
|
36
|
-
add_column :rapns_notifications, :delay_while_idle, :boolean, :
|
35
|
+
add_column :rapns_notifications, :collapse_key, :string, null: true
|
36
|
+
add_column :rapns_notifications, :delay_while_idle, :boolean, null: false, default: false
|
37
37
|
|
38
38
|
reg_ids_type = ActiveRecord::Base.connection.adapter_name.include?('Mysql') ? :mediumtext : :text
|
39
|
-
add_column :rapns_notifications, :registration_ids, reg_ids_type, :
|
40
|
-
add_column :rapns_notifications, :app_id, :integer, :
|
41
|
-
add_column :rapns_notifications, :retries, :integer, :
|
39
|
+
add_column :rapns_notifications, :registration_ids, reg_ids_type, null: true
|
40
|
+
add_column :rapns_notifications, :app_id, :integer, null: true
|
41
|
+
add_column :rapns_notifications, :retries, :integer, null: true, default: 0
|
42
42
|
|
43
43
|
AddGcm::Rapns::Notification.reset_column_information
|
44
44
|
AddGcm::Rapns::App.reset_column_information
|
@@ -47,30 +47,30 @@ class AddGcm < ActiveRecord::Migration
|
|
47
47
|
AddGcm::Rapns::Notification.update_all(['app_id = ?', app.id], ['app = ?', app.name])
|
48
48
|
end
|
49
49
|
|
50
|
-
change_column :rapns_notifications, :app_id, :integer, :
|
50
|
+
change_column :rapns_notifications, :app_id, :integer, null: false
|
51
51
|
remove_column :rapns_notifications, :app
|
52
52
|
|
53
53
|
if index_name_exists?(:rapns_notifications, "index_rapns_notifications_multi", true)
|
54
|
-
remove_index :rapns_notifications, :
|
54
|
+
remove_index :rapns_notifications, name: "index_rapns_notifications_multi"
|
55
55
|
elsif index_name_exists?(:rapns_notifications, "index_rapns_notifications_on_delivered_failed_deliver_after", false)
|
56
|
-
remove_index :rapns_notifications, :
|
56
|
+
remove_index :rapns_notifications, name: "index_rapns_notifications_on_delivered_failed_deliver_after"
|
57
57
|
end
|
58
|
-
add_index :rapns_notifications, [:app_id, :delivered, :failed, :deliver_after], :
|
58
|
+
add_index :rapns_notifications, [:app_id, :delivered, :failed, :deliver_after], name: "index_rapns_notifications_multi"
|
59
59
|
end
|
60
60
|
|
61
61
|
def self.down
|
62
|
-
AddGcm::Rapns::Notification.where(:
|
62
|
+
AddGcm::Rapns::Notification.where(type: 'Rapns::Gcm::Notification').delete_all
|
63
63
|
|
64
64
|
remove_column :rapns_notifications, :type
|
65
65
|
remove_column :rapns_apps, :type
|
66
66
|
|
67
|
-
change_column :rapns_notifications, :device_token, :string, { :
|
68
|
-
change_column :rapns_notifications, :expiry, :integer, { :
|
69
|
-
change_column :rapns_apps, :environment, :string, :
|
70
|
-
change_column :rapns_apps, :certificate, :text, :
|
67
|
+
change_column :rapns_notifications, :device_token, :string, { null: false, limit: 64 }
|
68
|
+
change_column :rapns_notifications, :expiry, :integer, { null: false, default: 1.day.to_i }
|
69
|
+
change_column :rapns_apps, :environment, :string, null: false
|
70
|
+
change_column :rapns_apps, :certificate, :text, null: false
|
71
71
|
|
72
|
-
change_column :rapns_notifications, :error_description, :string, :
|
73
|
-
change_column :rapns_notifications, :sound, :string, :
|
72
|
+
change_column :rapns_notifications, :error_description, :string, null: true, default: nil
|
73
|
+
change_column :rapns_notifications, :sound, :string, default: '1.aiff'
|
74
74
|
|
75
75
|
rename_column :rapns_notifications, :data, :attributes_for_device
|
76
76
|
rename_column :rapns_apps, :name, :key
|
@@ -82,7 +82,7 @@ class AddGcm < ActiveRecord::Migration
|
|
82
82
|
remove_column :rapns_notifications, :registration_ids
|
83
83
|
remove_column :rapns_notifications, :retries
|
84
84
|
|
85
|
-
add_column :rapns_notifications, :app, :string, :
|
85
|
+
add_column :rapns_notifications, :app, :string, null: true
|
86
86
|
|
87
87
|
AddGcm::Rapns::Notification.reset_column_information
|
88
88
|
AddGcm::Rapns::App.reset_column_information
|
@@ -92,11 +92,11 @@ class AddGcm < ActiveRecord::Migration
|
|
92
92
|
end
|
93
93
|
|
94
94
|
if index_name_exists?(:rapns_notifications, :index_rapns_notifications_multi, true)
|
95
|
-
|
95
|
+
remove_index :rapns_notifications, name: :index_rapns_notifications_multi
|
96
96
|
end
|
97
97
|
|
98
98
|
remove_column :rapns_notifications, :app_id
|
99
99
|
|
100
|
-
add_index :rapns_notifications, [:delivered, :failed, :deliver_after], :
|
100
|
+
add_index :rapns_notifications, [:delivered, :failed, :deliver_after], name: :index_rapns_notifications_multi
|
101
101
|
end
|
102
102
|
end
|
@@ -44,28 +44,28 @@ class AddRpush < ActiveRecord::Migration
|
|
44
44
|
class CreateRapnsNotifications < ActiveRecord::Migration
|
45
45
|
def self.up
|
46
46
|
create_table :rapns_notifications do |t|
|
47
|
-
t.integer :badge, :
|
48
|
-
t.string :device_token, :
|
49
|
-
t.string :sound, :
|
50
|
-
t.string :alert, :
|
51
|
-
t.text :attributes_for_device, :
|
52
|
-
t.integer :expiry, :
|
53
|
-
t.boolean :delivered, :
|
54
|
-
t.timestamp :delivered_at, :
|
55
|
-
t.boolean :failed, :
|
56
|
-
t.timestamp :failed_at, :
|
57
|
-
t.integer :error_code, :
|
58
|
-
t.string :error_description, :
|
59
|
-
t.timestamp :deliver_after, :
|
47
|
+
t.integer :badge, null: true
|
48
|
+
t.string :device_token, null: false, limit: 64
|
49
|
+
t.string :sound, null: true, default: "1.aiff"
|
50
|
+
t.string :alert, null: true
|
51
|
+
t.text :attributes_for_device, null: true
|
52
|
+
t.integer :expiry, null: false, default: 1.day.to_i
|
53
|
+
t.boolean :delivered, null: false, default: false
|
54
|
+
t.timestamp :delivered_at, null: true
|
55
|
+
t.boolean :failed, null: false, default: false
|
56
|
+
t.timestamp :failed_at, null: true
|
57
|
+
t.integer :error_code, null: true
|
58
|
+
t.string :error_description, null: true
|
59
|
+
t.timestamp :deliver_after, null: true
|
60
60
|
t.timestamps
|
61
61
|
end
|
62
62
|
|
63
|
-
add_index :rapns_notifications, [:delivered, :failed, :deliver_after], :
|
63
|
+
add_index :rapns_notifications, [:delivered, :failed, :deliver_after], name: 'index_rapns_notifications_multi'
|
64
64
|
end
|
65
65
|
|
66
66
|
def self.down
|
67
67
|
if index_name_exists?(:rapns_notifications, 'index_rapns_notifications_multi', true)
|
68
|
-
remove_index :rapns_notifications, :
|
68
|
+
remove_index :rapns_notifications, name: 'index_rapns_notifications_multi'
|
69
69
|
end
|
70
70
|
drop_table :rapns_notifications
|
71
71
|
end
|
@@ -74,8 +74,8 @@ class AddRpush < ActiveRecord::Migration
|
|
74
74
|
class CreateRapnsFeedback < ActiveRecord::Migration
|
75
75
|
def self.up
|
76
76
|
create_table :rapns_feedback do |t|
|
77
|
-
t.string :device_token, :
|
78
|
-
t.timestamp :failed_at, :
|
77
|
+
t.string :device_token, null: false, limit: 64
|
78
|
+
t.timestamp :failed_at, null: false
|
79
79
|
t.timestamps
|
80
80
|
end
|
81
81
|
|
@@ -92,7 +92,7 @@ class AddRpush < ActiveRecord::Migration
|
|
92
92
|
|
93
93
|
class AddAlertIsJsonToRapnsNotifications < ActiveRecord::Migration
|
94
94
|
def self.up
|
95
|
-
add_column :rapns_notifications, :alert_is_json, :boolean, :
|
95
|
+
add_column :rapns_notifications, :alert_is_json, :boolean, null: true, default: false
|
96
96
|
end
|
97
97
|
|
98
98
|
def self.down
|
@@ -102,8 +102,8 @@ class AddRpush < ActiveRecord::Migration
|
|
102
102
|
|
103
103
|
class AddAppToRapns < ActiveRecord::Migration
|
104
104
|
def self.up
|
105
|
-
add_column :rapns_notifications, :app, :string, :
|
106
|
-
add_column :rapns_feedback, :app, :string, :
|
105
|
+
add_column :rapns_notifications, :app, :string, null: true
|
106
|
+
add_column :rapns_feedback, :app, :string, null: true
|
107
107
|
end
|
108
108
|
|
109
109
|
def self.down
|
@@ -115,11 +115,11 @@ class AddRpush < ActiveRecord::Migration
|
|
115
115
|
class CreateRapnsApps < ActiveRecord::Migration
|
116
116
|
def self.up
|
117
117
|
create_table :rapns_apps do |t|
|
118
|
-
t.string :key, :
|
119
|
-
t.string :environment, :
|
120
|
-
t.text :certificate, :
|
121
|
-
t.string :password, :
|
122
|
-
t.integer :connections, :
|
118
|
+
t.string :key, null: false
|
119
|
+
t.string :environment, null: false
|
120
|
+
t.text :certificate, null: false
|
121
|
+
t.string :password, null: true
|
122
|
+
t.integer :connections, null: false, default: 1
|
123
123
|
t.timestamps
|
124
124
|
end
|
125
125
|
end
|
@@ -142,66 +142,66 @@ class AddRpush < ActiveRecord::Migration
|
|
142
142
|
end
|
143
143
|
|
144
144
|
def self.up
|
145
|
-
add_column :rapns_notifications, :type, :string, :
|
146
|
-
add_column :rapns_apps, :type, :string, :
|
145
|
+
add_column :rapns_notifications, :type, :string, null: true
|
146
|
+
add_column :rapns_apps, :type, :string, null: true
|
147
147
|
|
148
|
-
AddGcm::Rapns::Notification.update_all :
|
149
|
-
AddGcm::Rapns::App.update_all :
|
148
|
+
AddGcm::Rapns::Notification.update_all type: 'Rapns::Apns::Notification'
|
149
|
+
AddGcm::Rapns::App.update_all type: 'Rapns::Apns::App'
|
150
150
|
|
151
|
-
change_column :rapns_notifications, :type, :string, :
|
152
|
-
change_column :rapns_apps, :type, :string, :
|
153
|
-
change_column :rapns_notifications, :device_token, :string, { :
|
154
|
-
change_column :rapns_notifications, :expiry, :integer, { :
|
155
|
-
change_column :rapns_apps, :environment, :string, :
|
156
|
-
change_column :rapns_apps, :certificate, :text, :
|
151
|
+
change_column :rapns_notifications, :type, :string, null: false
|
152
|
+
change_column :rapns_apps, :type, :string, null: false
|
153
|
+
change_column :rapns_notifications, :device_token, :string, { null: true, limit: 64 }
|
154
|
+
change_column :rapns_notifications, :expiry, :integer, { null: true, default: 1.day.to_i }
|
155
|
+
change_column :rapns_apps, :environment, :string, null: true
|
156
|
+
change_column :rapns_apps, :certificate, :text, null: true, default: nil
|
157
157
|
|
158
|
-
change_column :rapns_notifications, :error_description, :text, :
|
159
|
-
change_column :rapns_notifications, :sound, :string, :
|
158
|
+
change_column :rapns_notifications, :error_description, :text, null: true, default: nil
|
159
|
+
change_column :rapns_notifications, :sound, :string, default: 'default'
|
160
160
|
|
161
161
|
rename_column :rapns_notifications, :attributes_for_device, :data
|
162
162
|
rename_column :rapns_apps, :key, :name
|
163
163
|
|
164
|
-
add_column :rapns_apps, :auth_key, :string, :
|
164
|
+
add_column :rapns_apps, :auth_key, :string, null: true
|
165
165
|
|
166
|
-
add_column :rapns_notifications, :collapse_key, :string, :
|
167
|
-
add_column :rapns_notifications, :delay_while_idle, :boolean, :
|
166
|
+
add_column :rapns_notifications, :collapse_key, :string, null: true
|
167
|
+
add_column :rapns_notifications, :delay_while_idle, :boolean, null: false, default: false
|
168
168
|
|
169
169
|
reg_ids_type = ActiveRecord::Base.connection.adapter_name.include?('Mysql') ? :mediumtext : :text
|
170
|
-
add_column :rapns_notifications, :registration_ids, reg_ids_type, :
|
171
|
-
add_column :rapns_notifications, :app_id, :integer, :
|
172
|
-
add_column :rapns_notifications, :retries, :integer, :
|
170
|
+
add_column :rapns_notifications, :registration_ids, reg_ids_type, null: true
|
171
|
+
add_column :rapns_notifications, :app_id, :integer, null: true
|
172
|
+
add_column :rapns_notifications, :retries, :integer, null: true, default: 0
|
173
173
|
|
174
174
|
AddGcm::Rapns::Notification.reset_column_information
|
175
175
|
AddGcm::Rapns::App.reset_column_information
|
176
176
|
|
177
177
|
AddGcm::Rapns::App.all.each do |app|
|
178
|
-
AddGcm::Rapns::Notification.update_all(
|
178
|
+
AddGcm::Rapns::Notification.where(app: app.name).update_all(app_id: app.id)
|
179
179
|
end
|
180
180
|
|
181
|
-
change_column :rapns_notifications, :app_id, :integer, :
|
181
|
+
change_column :rapns_notifications, :app_id, :integer, null: false
|
182
182
|
remove_column :rapns_notifications, :app
|
183
183
|
|
184
184
|
if index_name_exists?(:rapns_notifications, "index_rapns_notifications_multi", true)
|
185
|
-
remove_index :rapns_notifications, :
|
185
|
+
remove_index :rapns_notifications, name: "index_rapns_notifications_multi"
|
186
186
|
elsif index_name_exists?(:rapns_notifications, "index_rapns_notifications_on_delivered_failed_deliver_after", false)
|
187
|
-
remove_index :rapns_notifications, :
|
187
|
+
remove_index :rapns_notifications, name: "index_rapns_notifications_on_delivered_failed_deliver_after"
|
188
188
|
end
|
189
|
-
add_index :rapns_notifications, [:app_id, :delivered, :failed, :deliver_after], :
|
189
|
+
add_index :rapns_notifications, [:app_id, :delivered, :failed, :deliver_after], name: "index_rapns_notifications_multi"
|
190
190
|
end
|
191
191
|
|
192
192
|
def self.down
|
193
|
-
AddGcm::Rapns::Notification.where(:
|
193
|
+
AddGcm::Rapns::Notification.where(type: 'Rapns::Gcm::Notification').delete_all
|
194
194
|
|
195
195
|
remove_column :rapns_notifications, :type
|
196
196
|
remove_column :rapns_apps, :type
|
197
197
|
|
198
|
-
change_column :rapns_notifications, :device_token, :string, { :
|
199
|
-
change_column :rapns_notifications, :expiry, :integer, { :
|
200
|
-
change_column :rapns_apps, :environment, :string, :
|
201
|
-
change_column :rapns_apps, :certificate, :text, :
|
198
|
+
change_column :rapns_notifications, :device_token, :string, { null: false, limit: 64 }
|
199
|
+
change_column :rapns_notifications, :expiry, :integer, { null: false, default: 1.day.to_i }
|
200
|
+
change_column :rapns_apps, :environment, :string, null: false
|
201
|
+
change_column :rapns_apps, :certificate, :text, null: false
|
202
202
|
|
203
|
-
change_column :rapns_notifications, :error_description, :string, :
|
204
|
-
change_column :rapns_notifications, :sound, :string, :
|
203
|
+
change_column :rapns_notifications, :error_description, :string, null: true, default: nil
|
204
|
+
change_column :rapns_notifications, :sound, :string, default: '1.aiff'
|
205
205
|
|
206
206
|
rename_column :rapns_notifications, :data, :attributes_for_device
|
207
207
|
rename_column :rapns_apps, :name, :key
|
@@ -213,22 +213,22 @@ class AddRpush < ActiveRecord::Migration
|
|
213
213
|
remove_column :rapns_notifications, :registration_ids
|
214
214
|
remove_column :rapns_notifications, :retries
|
215
215
|
|
216
|
-
add_column :rapns_notifications, :app, :string, :
|
216
|
+
add_column :rapns_notifications, :app, :string, null: true
|
217
217
|
|
218
218
|
AddGcm::Rapns::Notification.reset_column_information
|
219
219
|
AddGcm::Rapns::App.reset_column_information
|
220
220
|
|
221
221
|
AddGcm::Rapns::App.all.each do |app|
|
222
|
-
AddGcm::Rapns::Notification.update_all(
|
222
|
+
AddGcm::Rapns::Notification.where(app_id: app.id).update_all(app: app.key)
|
223
223
|
end
|
224
224
|
|
225
225
|
if index_name_exists?(:rapns_notifications, :index_rapns_notifications_multi, true)
|
226
|
-
remove_index :rapns_notifications, :
|
226
|
+
remove_index :rapns_notifications, name: :index_rapns_notifications_multi
|
227
227
|
end
|
228
228
|
|
229
229
|
remove_column :rapns_notifications, :app_id
|
230
230
|
|
231
|
-
add_index :rapns_notifications, [:delivered, :failed, :deliver_after], :
|
231
|
+
add_index :rapns_notifications, [:delivered, :failed, :deliver_after], name: :index_rapns_notifications_multi
|
232
232
|
end
|
233
233
|
end
|
234
234
|
|
@@ -240,11 +240,11 @@ class AddRpush < ActiveRecord::Migration
|
|
240
240
|
end
|
241
241
|
|
242
242
|
def self.up
|
243
|
-
add_column :rapns_notifications, :uri, :string, :
|
243
|
+
add_column :rapns_notifications, :uri, :string, null: true
|
244
244
|
end
|
245
245
|
|
246
246
|
def self.down
|
247
|
-
AddWpns::Rapns::Notification.where(:
|
247
|
+
AddWpns::Rapns::Notification.where(type: 'Rapns::Wpns::Notification').delete_all
|
248
248
|
remove_column :rapns_notifications, :uri
|
249
249
|
end
|
250
250
|
end
|
@@ -257,14 +257,14 @@ class AddRpush < ActiveRecord::Migration
|
|
257
257
|
end
|
258
258
|
|
259
259
|
def self.up
|
260
|
-
add_column :rapns_apps, :client_id, :string, :
|
261
|
-
add_column :rapns_apps, :client_secret, :string, :
|
262
|
-
add_column :rapns_apps, :access_token, :string, :
|
263
|
-
add_column :rapns_apps, :access_token_expiration, :datetime, :
|
260
|
+
add_column :rapns_apps, :client_id, :string, null: true
|
261
|
+
add_column :rapns_apps, :client_secret, :string, null: true
|
262
|
+
add_column :rapns_apps, :access_token, :string, null: true
|
263
|
+
add_column :rapns_apps, :access_token_expiration, :datetime, null: true
|
264
264
|
end
|
265
265
|
|
266
266
|
def self.down
|
267
|
-
AddAdm::Rapns::Notification.where(:
|
267
|
+
AddAdm::Rapns::Notification.where(type: 'Rapns::Adm::Notification').delete_all
|
268
268
|
|
269
269
|
remove_column :rapns_apps, :client_id
|
270
270
|
remove_column :rapns_apps, :client_secret
|
@@ -339,7 +339,7 @@ class AddRpush < ActiveRecord::Migration
|
|
339
339
|
|
340
340
|
class AddFailAfterToRpushNotifications < ActiveRecord::Migration
|
341
341
|
def self.up
|
342
|
-
add_column :rpush_notifications, :fail_after, :timestamp, :
|
342
|
+
add_column :rpush_notifications, :fail_after, :timestamp, null: true
|
343
343
|
end
|
344
344
|
|
345
345
|
def self.down
|