20130305065226_scheduler_create.rb 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 :pid, :string, :limit => 250, :null => true
  12. t.column :note, :string, :limit => 250, :null => true
  13. t.column :active, :boolean, :null => false, :default => false
  14. t.column :updated_by_id, :integer, :null => false
  15. t.column :created_by_id, :integer, :null => false
  16. t.timestamps
  17. end
  18. add_index :schedulers, [:name], :unique => true
  19. Scheduler.create(
  20. :name => 'Check Channels',
  21. :method => 'Channel.fetch',
  22. :period => 30,
  23. :active => true,
  24. :updated_by_id => 1,
  25. :created_by_id => 1,
  26. )
  27. Scheduler.create(
  28. :name => 'Import OTRS diff load',
  29. :method => 'Import::OTRS.diff_loop',
  30. :period => 60 * 10,
  31. :active => true,
  32. :updated_by_id => 1,
  33. :created_by_id => 1,
  34. )
  35. Scheduler.create(
  36. :name => 'Generate Session data',
  37. :method => 'Session.jobs',
  38. :period => 60,
  39. :active => true,
  40. :updated_by_id => 1,
  41. :created_by_id => 1,
  42. )
  43. end
  44. def down
  45. drop_table :schedulers
  46. end
  47. end