13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/generators/templates/add_gcm.rb', line 13
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.update_all(['app_id = ?', app.id], ['app = ?', app.name])
end
change_column :rapns_notifications, :app_id, :integer, null: false
remove_column :rapns_notifications, :app
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
add_index :rapns_notifications, [:app_id, :delivered, :failed, :deliver_after], name: "index_rapns_notifications_multi"
end
|