20220322094105_new_cache_clear_job.rb 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class NewCacheClearJob < ActiveRecord::Migration[6.1]
  3. def change
  4. # return if it's a new setup
  5. return if !Setting.exists?(name: 'system_init_done')
  6. Scheduler.create_if_not_exists(
  7. name: 'Clean up cache.',
  8. method: 'CacheClearJob.perform_now',
  9. period: 1.day,
  10. prio: 2,
  11. active: true,
  12. updated_by_id: 1,
  13. created_by_id: 1,
  14. last_run: Time.zone.now,
  15. )
  16. change_column :knowledge_bases, :created_at, :datetime, limit: 3, null: false
  17. change_column :knowledge_bases, :updated_at, :datetime, limit: 3, null: false
  18. change_column :knowledge_base_translations, :created_at, :datetime, limit: 3, null: false
  19. change_column :knowledge_base_translations, :updated_at, :datetime, limit: 3, null: false
  20. change_column :knowledge_base_categories, :created_at, :datetime, limit: 3, null: false
  21. change_column :knowledge_base_categories, :updated_at, :datetime, limit: 3, null: false
  22. change_column :knowledge_base_category_translations, :created_at, :datetime, limit: 3, null: false
  23. change_column :knowledge_base_category_translations, :updated_at, :datetime, limit: 3, null: false
  24. change_column :knowledge_base_answers, :created_at, :datetime, limit: 3, null: false
  25. change_column :knowledge_base_answers, :updated_at, :datetime, limit: 3, null: false
  26. change_column :knowledge_base_answer_translations, :created_at, :datetime, limit: 3, null: false
  27. change_column :knowledge_base_answer_translations, :updated_at, :datetime, limit: 3, null: false
  28. change_column :knowledge_base_menu_items, :created_at, :datetime, limit: 3, null: false
  29. change_column :knowledge_base_menu_items, :updated_at, :datetime, limit: 3, null: false
  30. KnowledgeBase.reset_column_information
  31. KnowledgeBase::Translation.reset_column_information
  32. KnowledgeBase::Category.reset_column_information
  33. KnowledgeBase::Category::Translation.reset_column_information
  34. KnowledgeBase::Answer.reset_column_information
  35. KnowledgeBase::Answer::Translation.reset_column_information
  36. KnowledgeBase::MenuItem.reset_column_information
  37. end
  38. end