20171102000001_last_owner_update2.rb 886 B

1234567891011121314151617181920212223242526272829303132
  1. class LastOwnerUpdate2 < ActiveRecord::Migration[5.1]
  2. def up
  3. # return if it's a new setup
  4. return if !Setting.find_by(name: 'system_init_done')
  5. # reset assignment_timeout to prevent unwanted things happen
  6. Group.all.each do |group|
  7. group.assignment_timeout = nil
  8. group.save!
  9. end
  10. # check if column already exists
  11. if !ActiveRecord::Base.connection.column_exists?(:tickets, :last_owner_update_at)
  12. add_column :tickets, :last_owner_update_at, :timestamp, limit: 3, null: true
  13. add_index :tickets, [:last_owner_update_at]
  14. Ticket.reset_column_information
  15. end
  16. Scheduler.create_if_not_exists(
  17. name: 'Process auto unassign tickets',
  18. method: 'Ticket.process_auto_unassign',
  19. period: 10.minutes,
  20. prio: 1,
  21. active: true,
  22. updated_by_id: 1,
  23. created_by_id: 1,
  24. )
  25. Cache.clear
  26. end
  27. end