Skip to content
This repository has been archived by the owner on Mar 9, 2018. It is now read-only.

Fix migration failures on upgrade and rollback #181

Merged
merged 2 commits into from Nov 22, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/generators/templates/add_gcm.rb
Expand Up @@ -50,7 +50,11 @@ def self.up
change_column :rapns_notifications, :app_id, :integer, :null => false
remove_column :rapns_notifications, :app

remove_index :rapns_notifications, :name => "index_rapns_notifications_multi"
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

Expand Down Expand Up @@ -87,9 +91,10 @@ def self.down
Rapns::Notification.update_all(['app = ?', app.key], ['app_id = ?', app.id])
end

remove_index :rapns_notifications, :name => "index_rapns_notifications_multi"

remove_column :rapns_notifications, :app_id

remove_index :rapns_notifications, :name => "index_rapns_notifications_multi"
add_index :rapns_notifications, [:delivered, :failed, :deliver_after], :name => "index_rapns_notifications_multi"
end
end