Class: AddRpush::CreateRapnsNotifications

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/templates/add_rpush.rb

Class Method Summary collapse

Class Method Details

.downObject


66
67
68
69
70
71
# File 'lib/generators/templates/add_rpush.rb', line 66

def self.down
  if index_name_exists?(:rapns_notifications, 'index_rapns_notifications_multi', true)
    remove_index :rapns_notifications, name: 'index_rapns_notifications_multi'
  end
  drop_table :rapns_notifications
end

.upObject


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/generators/templates/add_rpush.rb', line 45

def self.up
  create_table :rapns_notifications do |t|
    t.integer   :badge,                 null: true
    t.string    :device_token,          null: false, limit: 64
    t.string    :sound,                 null: true,  default: "1.aiff"
    t.string    :alert,                 null: true
    t.text      :attributes_for_device, null: true
    t.integer   :expiry,                null: false, default: 1.day.to_i
    t.boolean   :delivered,             null: false, default: false
    t.timestamp :delivered_at,          null: true
    t.boolean   :failed,                null: false, default: false
    t.timestamp :failed_at,             null: true
    t.integer   :error_code,            null: true
    t.string    :error_description,     null: true
    t.timestamp :deliver_after,         null: true
    t.timestamps
  end

  add_index :rapns_notifications, [:delivered, :failed, :deliver_after], name: 'index_rapns_notifications_multi'
end