158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
# File 'lib/generators/templates/add_rpush.rb', line 158
def self.up
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'
change_column :rapns_notifications, :type, :string, null: false
change_column :rapns_apps, :type, :string, null: false
change_column :rapns_notifications, :device_token, :string, { null: true, limit: 64 }
change_column :rapns_notifications, :expiry, :integer, { null: true, default: 1.day.to_i }
change_column :rapns_apps, :environment, :string, null: true
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'
rename_column :rapns_notifications, :attributes_for_device, :data
rename_column :rapns_apps, :key, :name
add_column :rapns_apps, :auth_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
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
AddGcm::Rapns::Notification.reset_column_information
AddGcm::Rapns::App.reset_column_information
AddGcm::Rapns::App.all.each do |app|
AddGcm::Rapns::Notification.where(app: app.name).update_all(app_id: app.id)
end
change_column :rapns_notifications, :app_id, :integer, null: false
remove_column :rapns_notifications, :app
if ActiveRecord.version >= Gem::Version.new('5.1')
if index_name_exists?(:rapns_notifications, "index_rapns_notifications_multi")
remove_index :rapns_notifications, name: "index_rapns_notifications_multi"
elsif index_name_exists?(:rapns_notifications, "index_rapns_notifications_on_delivered_failed_deliver_after")
remove_index :rapns_notifications, name: "index_rapns_notifications_on_delivered_failed_deliver_after"
end
else
if index_name_exists?(:rapns_notifications, "index_rapns_notifications_multi", true)
remove_index :rapns_notifications, name: "index_rapns_notifications_multi"
elsif index_name_exists?(:rapns_notifications, "index_rapns_notifications_on_delivered_failed_deliver_after", false)
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"
end
|