20160417000002_add_http_log.rb 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. class AddHttpLog < ActiveRecord::Migration
  2. def up
  3. create_table :http_logs do |t|
  4. t.column :direction, :string, limit: 20, null: false
  5. t.column :facility, :string, limit: 100, null: false
  6. t.column :method, :string, limit: 100, null: false
  7. t.column :url, :string, limit: 255, null: false
  8. t.column :status, :string, limit: 20, null: true
  9. t.column :ip, :string, limit: 50, null: true
  10. t.column :request, :string, limit: 10_000, null: false
  11. t.column :response, :string, limit: 10_000, null: false
  12. t.column :updated_by_id, :integer, null: true
  13. t.column :created_by_id, :integer, null: true
  14. t.timestamps null: false
  15. end
  16. add_index :http_logs, [:facility]
  17. add_index :http_logs, [:created_by_id]
  18. add_index :http_logs, [:created_at]
  19. Scheduler.create_if_not_exists(
  20. name: 'Cleanup HttpLog',
  21. method: 'HttpLog.cleanup',
  22. period: 24 * 60 * 60,
  23. prio: 2,
  24. active: true,
  25. updated_by_id: 1,
  26. created_by_id: 1,
  27. )
  28. end
  29. end