20171102000001_last_owner_update2.rb 1008 B

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