Commit 6af27911326fa23d28852e9e440cd9f497a37c65

Authored by Antonio Terceiro
1 parent f58c398a

Initializers: workaround DelayedJob usage on upgrades

No code on initializers should ever touch the database. During upgrades,
that code will run when running migrations, i.e. while the database is
still outdated.
config/initializers/activities_counter_cache.rb
1   -if Delayed::Backend::ActiveRecord::Job.table_exists?
  1 +if Delayed::Backend::ActiveRecord::Job.table_exists? &&
  2 + Delayed::Backend::ActiveRecord::Job.attribute_names.include?('queue')
2 3 job = Delayed::Backend::ActiveRecord::Job.all :conditions => ['handler LIKE ?', "%ActivitiesCounterCacheJob%"]
3 4 if job.blank?
4 5 Delayed::Backend::ActiveRecord::Job.enqueue(ActivitiesCounterCacheJob.new, {:priority => -3})
... ...
config/initializers/person_notification.rb
1   -if Delayed::Backend::ActiveRecord::Job.table_exists?
  1 +if Delayed::Backend::ActiveRecord::Job.table_exists? &&
  2 + Delayed::Backend::ActiveRecord::Job.attribute_names.include?('queue')
2 3 PersonNotifier.schedule_all_next_notification_mail
3 4 end
... ...