20130305065226_scheduler_create.rb 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. require 'scheduler'
  2. require 'setting'
  3. class SchedulerCreate < ActiveRecord::Migration
  4. def up
  5. create_table :schedulers do |t|
  6. t.column :name, :string, limit: 250, null: false
  7. t.column :method, :string, limit: 250, null: false
  8. t.column :period, :integer, null: true
  9. t.column :running, :integer, null: false, default: false
  10. t.column :last_run, :timestamp, null: true
  11. t.column :prio, :integer, null: false
  12. t.column :pid, :string, limit: 250, null: true
  13. t.column :note, :string, limit: 250, null: true
  14. t.column :active, :boolean, null: false, default: false
  15. t.column :updated_by_id, :integer, null: false
  16. t.column :created_by_id, :integer, null: false
  17. t.timestamps
  18. end
  19. add_index :schedulers, [:name], unique: true
  20. Scheduler.create_or_update(
  21. name: 'Import OTRS diff load',
  22. method: 'Import::OTRS.diff_worker',
  23. period: 60 * 3,
  24. prio: 1,
  25. active: true,
  26. updated_by_id: 1,
  27. created_by_id: 1,
  28. )
  29. Scheduler.create_or_update(
  30. name: 'Check Channels',
  31. method: 'Channel.fetch',
  32. period: 30,
  33. prio: 1,
  34. active: true,
  35. updated_by_id: 1,
  36. created_by_id: 1,
  37. )
  38. Scheduler.create_or_update(
  39. name: 'Generate Session data',
  40. method: 'Sessions.jobs',
  41. period: 60,
  42. prio: 1,
  43. active: true,
  44. updated_by_id: 1,
  45. created_by_id: 1,
  46. )
  47. Scheduler.create_or_update(
  48. name: 'Cleanup expired sessions',
  49. method: 'SessionHelper.cleanup_expired',
  50. period: 60 * 60 * 24,
  51. prio: 2,
  52. active: true,
  53. updated_by_id: 1,
  54. created_by_id: 1,
  55. )
  56. end
  57. def down
  58. drop_table :schedulers
  59. end
  60. end