Class: AlterApnDevices

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/apn_on_rails/install/templates/003_alter_apn_devices.rb

Overview

:nodoc:

Defined Under Namespace

Modules: APN

Class Method Summary collapse

Class Method Details

.downObject



20
21
22
23
24
# File 'lib/generators/apn_on_rails/install/templates/003_alter_apn_devices.rb', line 20

def self.down
  change_column :apn_devices, :token, :string
  remove_index :apn_devices, :column => :token
  remove_column :apn_devices, :last_registered_at
end

.upObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/generators/apn_on_rails/install/templates/003_alter_apn_devices.rb', line 9

def self.up
  add_column :apn_devices, :last_registered_at, :datetime
  
  APN::Device.all.each do |device|
    device.last_registered_at = device.created_at
    device.save!
  end
  change_column :apn_devices, :token, :string, :size => 100, :null => false
  add_index :apn_devices, :token, :unique => true
end