Method: RenameRapnsToRpush.up

Defined in:
lib/generators/templates/rename_rapns_to_rpush.rb

.upObject



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::MAJOR >= 5 && ActiveRecord::VERSION::MINOR >= 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::MAJOR >= 5 && ActiveRecord::VERSION::MINOR >= 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