gwong-apn_on_rails 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -0
- data/.specification +80 -0
- data/Gemfile +19 -0
- data/Gemfile.lock +47 -0
- data/LICENSE +21 -0
- data/README +179 -0
- data/README.textile +209 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/apn_on_rails.gemspec +144 -0
- data/autotest/discover.rb +1 -0
- data/generators/apn_migrations_generator.rb +31 -0
- data/generators/templates/apn_migrations/001_create_apn_devices.rb +13 -0
- data/generators/templates/apn_migrations/002_create_apn_notifications.rb +23 -0
- data/generators/templates/apn_migrations/003_alter_apn_devices.rb +25 -0
- data/generators/templates/apn_migrations/004_create_apn_apps.rb +18 -0
- data/generators/templates/apn_migrations/005_create_groups.rb +23 -0
- data/generators/templates/apn_migrations/006_alter_apn_groups.rb +11 -0
- data/generators/templates/apn_migrations/007_create_device_groups.rb +27 -0
- data/generators/templates/apn_migrations/008_create_apn_group_notifications.rb +23 -0
- data/generators/templates/apn_migrations/009_create_pull_notifications.rb +16 -0
- data/generators/templates/apn_migrations/010_alter_apn_notifications.rb +21 -0
- data/generators/templates/apn_migrations/011_make_device_token_index_nonunique.rb +11 -0
- data/generators/templates/apn_migrations/012_add_launch_notification_to_apn_pull_notifications.rb +9 -0
- data/lib/apn_on_rails.rb +4 -0
- data/lib/apn_on_rails/apn_on_rails.rb +81 -0
- data/lib/apn_on_rails/app/models/apn/app.rb +150 -0
- data/lib/apn_on_rails/app/models/apn/base.rb +9 -0
- data/lib/apn_on_rails/app/models/apn/device.rb +49 -0
- data/lib/apn_on_rails/app/models/apn/device_grouping.rb +16 -0
- data/lib/apn_on_rails/app/models/apn/group.rb +12 -0
- data/lib/apn_on_rails/app/models/apn/group_notification.rb +79 -0
- data/lib/apn_on_rails/app/models/apn/notification.rb +93 -0
- data/lib/apn_on_rails/app/models/apn/pull_notification.rb +28 -0
- data/lib/apn_on_rails/libs/connection.rb +70 -0
- data/lib/apn_on_rails/libs/feedback.rb +39 -0
- data/lib/apn_on_rails/tasks/apn.rake +30 -0
- data/lib/apn_on_rails/tasks/db.rake +19 -0
- data/lib/apn_on_rails_tasks.rb +3 -0
- data/spec/active_record/setup_ar.rb +19 -0
- data/spec/apn_on_rails/app/models/apn/app_spec.rb +226 -0
- data/spec/apn_on_rails/app/models/apn/device_spec.rb +60 -0
- data/spec/apn_on_rails/app/models/apn/group_notification_spec.rb +66 -0
- data/spec/apn_on_rails/app/models/apn/notification_spec.rb +71 -0
- data/spec/apn_on_rails/app/models/apn/pull_notification_spec.rb +100 -0
- data/spec/apn_on_rails/libs/connection_spec.rb +40 -0
- data/spec/apn_on_rails/libs/feedback_spec.rb +43 -0
- data/spec/extensions/string.rb +10 -0
- data/spec/factories/app_factory.rb +27 -0
- data/spec/factories/device_factory.rb +29 -0
- data/spec/factories/device_grouping_factory.rb +22 -0
- data/spec/factories/group_factory.rb +27 -0
- data/spec/factories/group_notification_factory.rb +22 -0
- data/spec/factories/notification_factory.rb +22 -0
- data/spec/factories/pull_notification_factory.rb +22 -0
- data/spec/fixtures/hexa.bin +1 -0
- data/spec/fixtures/message_for_sending.bin +0 -0
- data/spec/rails_root/config/apple_push_notification_development.pem +19 -0
- data/spec/spec_helper.rb +55 -0
- metadata +282 -0
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "apn_on_rails"
|
16
|
+
gem.summary = %Q{Apple Push Notifications on Rails}
|
17
|
+
|
18
|
+
gem.description = %Q{APN on Rails is a Ruby on Rails gem that allows you to
|
19
|
+
easily add Apple Push Notification (iPhone) support to your Rails application.
|
20
|
+
}
|
21
|
+
|
22
|
+
gem.email = "tech-team@prx.org"
|
23
|
+
gem.homepage = "http://github.com/PRX/apn_on_rails"
|
24
|
+
gem.authors = ["markbates", "Rebecca Nesson"]
|
25
|
+
end
|
26
|
+
#Jeweler::RubygemsDotOrgsTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "apn #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.4.2
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{gwong-apn_on_rails}
|
8
|
+
s.version = "0.4.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["markbates", "Rebecca Nesson"]
|
12
|
+
s.date = %q{2011-01-04}
|
13
|
+
s.description = %q{APN on Rails is a Ruby on Rails gem that allows you to
|
14
|
+
easily add Apple Push Notification (iPhone) support to your Rails application.
|
15
|
+
}
|
16
|
+
s.email = %q{tech-team@prx.org}
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README",
|
20
|
+
"README.textile"
|
21
|
+
]
|
22
|
+
s.files = [
|
23
|
+
".rspec",
|
24
|
+
".specification",
|
25
|
+
"Gemfile",
|
26
|
+
"Gemfile.lock",
|
27
|
+
"LICENSE",
|
28
|
+
"README",
|
29
|
+
"README.textile",
|
30
|
+
"Rakefile",
|
31
|
+
"VERSION",
|
32
|
+
"apn_on_rails.gemspec",
|
33
|
+
"autotest/discover.rb",
|
34
|
+
"generators/apn_migrations_generator.rb",
|
35
|
+
"generators/templates/apn_migrations/001_create_apn_devices.rb",
|
36
|
+
"generators/templates/apn_migrations/002_create_apn_notifications.rb",
|
37
|
+
"generators/templates/apn_migrations/003_alter_apn_devices.rb",
|
38
|
+
"generators/templates/apn_migrations/004_create_apn_apps.rb",
|
39
|
+
"generators/templates/apn_migrations/005_create_groups.rb",
|
40
|
+
"generators/templates/apn_migrations/006_alter_apn_groups.rb",
|
41
|
+
"generators/templates/apn_migrations/007_create_device_groups.rb",
|
42
|
+
"generators/templates/apn_migrations/008_create_apn_group_notifications.rb",
|
43
|
+
"generators/templates/apn_migrations/009_create_pull_notifications.rb",
|
44
|
+
"generators/templates/apn_migrations/010_alter_apn_notifications.rb",
|
45
|
+
"generators/templates/apn_migrations/011_make_device_token_index_nonunique.rb",
|
46
|
+
"generators/templates/apn_migrations/012_add_launch_notification_to_apn_pull_notifications.rb",
|
47
|
+
"lib/apn_on_rails.rb",
|
48
|
+
"lib/apn_on_rails/apn_on_rails.rb",
|
49
|
+
"lib/apn_on_rails/app/models/apn/app.rb",
|
50
|
+
"lib/apn_on_rails/app/models/apn/base.rb",
|
51
|
+
"lib/apn_on_rails/app/models/apn/device.rb",
|
52
|
+
"lib/apn_on_rails/app/models/apn/device_grouping.rb",
|
53
|
+
"lib/apn_on_rails/app/models/apn/group.rb",
|
54
|
+
"lib/apn_on_rails/app/models/apn/group_notification.rb",
|
55
|
+
"lib/apn_on_rails/app/models/apn/notification.rb",
|
56
|
+
"lib/apn_on_rails/app/models/apn/pull_notification.rb",
|
57
|
+
"lib/apn_on_rails/libs/connection.rb",
|
58
|
+
"lib/apn_on_rails/libs/feedback.rb",
|
59
|
+
"lib/apn_on_rails/tasks/apn.rake",
|
60
|
+
"lib/apn_on_rails/tasks/db.rake",
|
61
|
+
"lib/apn_on_rails_tasks.rb",
|
62
|
+
"spec/active_record/setup_ar.rb",
|
63
|
+
"spec/apn_on_rails/app/models/apn/app_spec.rb",
|
64
|
+
"spec/apn_on_rails/app/models/apn/device_spec.rb",
|
65
|
+
"spec/apn_on_rails/app/models/apn/group_notification_spec.rb",
|
66
|
+
"spec/apn_on_rails/app/models/apn/notification_spec.rb",
|
67
|
+
"spec/apn_on_rails/app/models/apn/pull_notification_spec.rb",
|
68
|
+
"spec/apn_on_rails/libs/connection_spec.rb",
|
69
|
+
"spec/apn_on_rails/libs/feedback_spec.rb",
|
70
|
+
"spec/extensions/string.rb",
|
71
|
+
"spec/factories/app_factory.rb",
|
72
|
+
"spec/factories/device_factory.rb",
|
73
|
+
"spec/factories/device_grouping_factory.rb",
|
74
|
+
"spec/factories/group_factory.rb",
|
75
|
+
"spec/factories/group_notification_factory.rb",
|
76
|
+
"spec/factories/notification_factory.rb",
|
77
|
+
"spec/factories/pull_notification_factory.rb",
|
78
|
+
"spec/fixtures/hexa.bin",
|
79
|
+
"spec/fixtures/message_for_sending.bin",
|
80
|
+
"spec/rails_root/config/apple_push_notification_development.pem",
|
81
|
+
"spec/spec_helper.rb"
|
82
|
+
]
|
83
|
+
s.homepage = %q{http://github.com/PRX/apn_on_rails}
|
84
|
+
s.require_paths = ["lib"]
|
85
|
+
s.rubygems_version = %q{1.3.7}
|
86
|
+
s.summary = %q{Apple Push Notifications on Rails}
|
87
|
+
s.test_files = [
|
88
|
+
"spec/active_record/setup_ar.rb",
|
89
|
+
"spec/apn_on_rails/app/models/apn/app_spec.rb",
|
90
|
+
"spec/apn_on_rails/app/models/apn/device_spec.rb",
|
91
|
+
"spec/apn_on_rails/app/models/apn/group_notification_spec.rb",
|
92
|
+
"spec/apn_on_rails/app/models/apn/notification_spec.rb",
|
93
|
+
"spec/apn_on_rails/app/models/apn/pull_notification_spec.rb",
|
94
|
+
"spec/apn_on_rails/libs/connection_spec.rb",
|
95
|
+
"spec/apn_on_rails/libs/feedback_spec.rb",
|
96
|
+
"spec/extensions/string.rb",
|
97
|
+
"spec/factories/app_factory.rb",
|
98
|
+
"spec/factories/device_factory.rb",
|
99
|
+
"spec/factories/device_grouping_factory.rb",
|
100
|
+
"spec/factories/group_factory.rb",
|
101
|
+
"spec/factories/group_notification_factory.rb",
|
102
|
+
"spec/factories/notification_factory.rb",
|
103
|
+
"spec/factories/pull_notification_factory.rb",
|
104
|
+
"spec/spec_helper.rb"
|
105
|
+
]
|
106
|
+
|
107
|
+
if s.respond_to? :specification_version then
|
108
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
109
|
+
s.specification_version = 3
|
110
|
+
|
111
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
112
|
+
s.add_runtime_dependency(%q<configatron>, [">= 0"])
|
113
|
+
s.add_development_dependency(%q<autotest>, [">= 0"])
|
114
|
+
s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
|
115
|
+
s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
|
116
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
117
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.0"])
|
118
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
119
|
+
s.add_development_dependency(%q<actionpack>, ["~> 2.3.0"])
|
120
|
+
s.add_development_dependency(%q<activerecord>, ["~> 2.3.0"])
|
121
|
+
else
|
122
|
+
s.add_dependency(%q<configatron>, [">= 0"])
|
123
|
+
s.add_dependency(%q<autotest>, [">= 0"])
|
124
|
+
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
125
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0"])
|
126
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
127
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.0"])
|
128
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
129
|
+
s.add_dependency(%q<actionpack>, ["~> 2.3.0"])
|
130
|
+
s.add_dependency(%q<activerecord>, ["~> 2.3.0"])
|
131
|
+
end
|
132
|
+
else
|
133
|
+
s.add_dependency(%q<configatron>, [">= 0"])
|
134
|
+
s.add_dependency(%q<autotest>, [">= 0"])
|
135
|
+
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
136
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0"])
|
137
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
138
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.0"])
|
139
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
140
|
+
s.add_dependency(%q<actionpack>, ["~> 2.3.0"])
|
141
|
+
s.add_dependency(%q<activerecord>, ["~> 2.3.0"])
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
Autotest.add_discovery { "rspec2" }
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rails_generator'
|
2
|
+
# Generates the migrations necessary for APN on Rails.
|
3
|
+
# This should be run upon install and upgrade of the
|
4
|
+
# APN on Rails gem.
|
5
|
+
#
|
6
|
+
# $ ruby script/generate apn_migrations
|
7
|
+
class ApnMigrationsGenerator < Rails::Generator::Base
|
8
|
+
|
9
|
+
def manifest # :nodoc:
|
10
|
+
record do |m|
|
11
|
+
timestamp = Time.now.utc.strftime("%Y%m%d%H%M%S")
|
12
|
+
db_migrate_path = File.join('db', 'migrate')
|
13
|
+
|
14
|
+
m.directory(db_migrate_path)
|
15
|
+
|
16
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'templates', 'apn_migrations', '*.rb')).sort.each_with_index do |f, i|
|
17
|
+
f = File.basename(f)
|
18
|
+
f.match(/\d+\_(.+)/)
|
19
|
+
timestamp = timestamp.succ
|
20
|
+
if Dir.glob(File.join(db_migrate_path, "*_#{$1}")).empty?
|
21
|
+
m.file(File.join('apn_migrations', f),
|
22
|
+
File.join(db_migrate_path, "#{timestamp}_#{$1}"),
|
23
|
+
{:collision => :skip})
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end # record
|
28
|
+
|
29
|
+
end # manifest
|
30
|
+
|
31
|
+
end # ApnMigrationsGenerator
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class CreateApnNotifications < ActiveRecord::Migration # :nodoc:
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
|
5
|
+
create_table :apn_notifications do |t|
|
6
|
+
t.integer :device_id, :null => false
|
7
|
+
t.integer :errors_nb, :default => 0 # used for storing errors from apple feedbacks
|
8
|
+
t.string :device_language, :size => 5 # if you don't want to send localized strings
|
9
|
+
t.string :sound
|
10
|
+
t.string :alert, :size => 150
|
11
|
+
t.integer :badge
|
12
|
+
t.datetime :sent_at
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
|
16
|
+
add_index :apn_notifications, :device_id
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.down
|
20
|
+
drop_table :apn_notifications
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class AlterApnDevices < ActiveRecord::Migration # :nodoc:
|
2
|
+
|
3
|
+
module APN # :nodoc:
|
4
|
+
class Device < ActiveRecord::Base # :nodoc:
|
5
|
+
set_table_name 'apn_devices'
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.up
|
10
|
+
add_column :apn_devices, :last_registered_at, :datetime
|
11
|
+
|
12
|
+
APN::Device.all.each do |device|
|
13
|
+
device.last_registered_at = device.created_at
|
14
|
+
device.save!
|
15
|
+
end
|
16
|
+
change_column :apn_devices, :token, :string, :size => 100, :null => false
|
17
|
+
add_index :apn_devices, :token, :unique => true
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.down
|
21
|
+
change_column :apn_devices, :token, :string
|
22
|
+
remove_index :apn_devices, :column => :token
|
23
|
+
remove_column :apn_devices, :last_registered_at
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateApnApps < ActiveRecord::Migration # :nodoc:
|
2
|
+
def self.up
|
3
|
+
create_table :apn_apps do |t|
|
4
|
+
t.text :apn_dev_cert
|
5
|
+
t.text :apn_prod_cert
|
6
|
+
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
|
10
|
+
add_column :apn_devices, :app_id, :integer
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
drop_table :apn_apps
|
16
|
+
remove_column :apn_devices, :app_id
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class CreateGroups < ActiveRecord::Migration # :nodoc:
|
2
|
+
def self.up
|
3
|
+
create_table :apn_groups do |t|
|
4
|
+
t.column :name, :string
|
5
|
+
|
6
|
+
t.timestamps
|
7
|
+
end
|
8
|
+
|
9
|
+
create_table :apn_devices_apn_groups, :id => false do |t|
|
10
|
+
t.column :group_id, :integer
|
11
|
+
t.column :device_id, :integer
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index :apn_devices_apn_groups, [:group_id, :device_id]
|
15
|
+
add_index :apn_devices_apn_groups, :device_id
|
16
|
+
add_index :apn_devices_apn_groups, :group_id
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.down
|
20
|
+
drop_table :apn_groups
|
21
|
+
drop_table :apn_devices_apn_groups
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class CreateDeviceGroups < ActiveRecord::Migration # :nodoc:
|
2
|
+
def self.up
|
3
|
+
drop_table :apn_devices_apn_groups
|
4
|
+
|
5
|
+
create_table :apn_device_groupings do |t|
|
6
|
+
t.column :group_id, :integer
|
7
|
+
t.column :device_id, :integer
|
8
|
+
end
|
9
|
+
|
10
|
+
add_index :apn_device_groupings, [:group_id, :device_id]
|
11
|
+
add_index :apn_device_groupings, :device_id
|
12
|
+
add_index :apn_device_groupings, :group_id
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.down
|
16
|
+
drop_table :apn_device_groupings
|
17
|
+
|
18
|
+
create_table :apn_devices_apn_groups, :id => false do |t|
|
19
|
+
t.column :group_id, :integer
|
20
|
+
t.column :device_id, :integer
|
21
|
+
end
|
22
|
+
|
23
|
+
add_index :apn_devices_apn_groups, [:group_id, :device_id]
|
24
|
+
add_index :apn_devices_apn_groups, :device_id
|
25
|
+
add_index :apn_devices_apn_groups, :group_id
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class CreateApnGroupNotifications < ActiveRecord::Migration # :nodoc:
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
|
5
|
+
create_table :apn_group_notifications do |t|
|
6
|
+
t.integer :group_id, :null => false
|
7
|
+
t.string :device_language, :size => 5 # if you don't want to send localized strings
|
8
|
+
t.string :sound
|
9
|
+
t.string :alert, :size => 150
|
10
|
+
t.integer :badge
|
11
|
+
t.text :custom_properties
|
12
|
+
t.datetime :sent_at
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
|
16
|
+
add_index :apn_group_notifications, :group_id
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.down
|
20
|
+
drop_table :apn_group_notifications
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreatePullNotifications < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :apn_pull_notifications do |t|
|
4
|
+
t.integer :app_id
|
5
|
+
t.string :title
|
6
|
+
t.string :content
|
7
|
+
t.string :link
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :apn_pull_notifications
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class AlterApnNotifications < ActiveRecord::Migration # :nodoc:
|
2
|
+
|
3
|
+
module APN # :nodoc:
|
4
|
+
class Notification < ActiveRecord::Base # :nodoc:
|
5
|
+
set_table_name 'apn_notifications'
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.up
|
10
|
+
unless APN::Notification.column_names.include?("custom_properties")
|
11
|
+
add_column :apn_notifications, :custom_properties, :text
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.down
|
16
|
+
if APN::Notification.column_names.include?("custom_properties")
|
17
|
+
remove_column :apn_notifications, :custom_properties
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|