Skip to content

Commit

Permalink
If you upgrade from a previous version of apn_on_rails some of the
Browse files Browse the repository at this point in the history
    migrations could have been already generated. In these cases, just
    print a warning message a keep going on.
  • Loading branch information
Matteo Centenaro committed Jun 28, 2011
1 parent 0a78d4b commit 552c25f
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions lib/generators/apn_on_rails/migrations_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,30 @@ def create_migrations
# Dir.glob(File.join(self.class.base_root, 'templates', 'migrations', '*.rb')).sort.each do |file|
# migration_template("#{File.basename(file)}", "db/migrate/#{File.basename(file)}");
# end

migration_template('create_apn_devices.rb', 'db/migrate/create_apn_devices.rb')
migration_template('create_apn_notifications.rb', 'db/migrate/create_apn_notifications.rb')
migration_template('create_apn_apps.rb', 'db/migrate/create_apn_apps.rb')
migration_template('alter_apn_devices.rb', 'db/migrate/alter_apn_devices.rb')
migration_template('create_groups.rb', 'db/migrate/create_groups.rb')
migration_template('alter_apn_groups.rb', 'db/migrate/alter_apn_groups.rb')
migration_template('create_device_groups.rb', 'db/migrate/create_device_groups.rb')
migration_template('create_apn_group_notifications.rb', 'db/migrate/create_apn_group_notifications.rb')
migration_template('create_pull_notifications.rb', 'db/migrate/create_pull_notifications.rb')
migration_template('alter_apn_notifications.rb', 'db/migrate/alter_apn_notifications.rb')
migration_template('make_device_token_index_nonunique.rb', 'db/migrate/make_device_token_index_nonunique.rb')
migration_template('add_launch_notification_to_apn_pull_notifications.rb', 'db/migrate/add_launch_notification_to_apn_pull_notifications.rb')


templates = {
'create_apn_devices.rb' => 'db/migrate/create_apn_devices.rb',
'create_apn_notifications.rb' => 'db/migrate/create_apn_notifications.rb',
'create_apn_apps.rb' => 'db/migrate/create_apn_apps.rb',
'alter_apn_devices.rb' => 'db/migrate/alter_apn_devices.rb',
'create_groups.rb' => 'db/migrate/create_groups.rb',
'alter_apn_groups.rb' => 'db/migrate/alter_apn_groups.rb',
'create_device_groups.rb' => 'db/migrate/create_device_groups.rb',
'create_apn_group_notifications.rb' => 'db/migrate/create_apn_group_notifications.rb',
'create_pull_notifications.rb' => 'db/migrate/create_pull_notifications.rb',
'alter_apn_notifications.rb' => 'db/migrate/alter_apn_notifications.rb',
'make_device_token_index_nonunique.rb' => 'db/migrate/make_device_token_index_nonunique.rb',
'add_launch_notification_to_apn_pull_notifications.rb' => 'db/migrate/add_launch_notification_to_apn_pull_notifications.rb',
}

templates.each_pair do |name, path|
begin
migration_template(name, path)
rescue => err
puts "WARNING: #{err.message}"
end
end
end
end
end
end

0 comments on commit 552c25f

Please sign in to comment.