Class: RenameRapnsToRpush
- Inherits:
-
Object
- Object
- RenameRapnsToRpush
- Defined in:
- lib/generators/templates/rename_rapns_to_rpush.rb
Defined Under Namespace
Modules: Rpush
Class Method Summary collapse
Class Method Details
.down ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/generators/templates/rename_rapns_to_rpush.rb', line 52 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::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 ActiveRecord.version >= Gem::Version.new('5.1') if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi) rename_index :rpush_notifications, :index_rpush_notifications_multi, :index_rapns_notifications_multi end else if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi, true) rename_index :rpush_notifications, :index_rpush_notifications_multi, :index_rapns_notifications_multi end end if ActiveRecord.version >= Gem::Version.new('5.1') 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 else if index_name_exists?(:rpush_feedback, :index_rpush_feedback_on_device_token, true) rename_index :rpush_feedback, :index_rpush_feedback_on_device_token, :index_rapns_feedback_on_device_token end end rename_table :rpush_notifications, :rapns_notifications rename_table :rpush_apps, :rapns_apps rename_table :rpush_feedback, :rapns_feedback end |
.up ⇒ Object
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 |
# File 'lib/generators/templates/rename_rapns_to_rpush.rb', line 16 def self.up rename_table :rapns_notifications, :rpush_notifications rename_table :rapns_apps, :rpush_apps rename_table :rapns_feedback, :rpush_feedback if ActiveRecord.version >= Gem::Version.new('5.1') if index_name_exists?(:rpush_notifications, :index_rapns_notifications_multi) rename_index :rpush_notifications, :index_rapns_notifications_multi, :index_rpush_notifications_multi end else if index_name_exists?(:rpush_notifications, :index_rapns_notifications_multi, true) rename_index :rpush_notifications, :index_rapns_notifications_multi, :index_rpush_notifications_multi end end if ActiveRecord.version >= Gem::Version.new('5.1') 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 else if index_name_exists?(:rpush_feedback, :index_rapns_feedback_on_device_token, true) rename_index :rpush_feedback, :index_rapns_feedback_on_device_token, :index_rpush_feedback_on_device_token end end 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') end |
.update_type(model, from, to) ⇒ Object
12 13 14 |
# File 'lib/generators/templates/rename_rapns_to_rpush.rb', line 12 def self.update_type(model, from, to) model.where(type: from).update_all(type: to) end |