20170116000001_add_ticket_time_accounting_373.rb 984 B

12345678910111213141516171819202122232425
  1. class AddTicketTimeAccounting373 < ActiveRecord::Migration[4.2]
  2. def up
  3. # return if it's a new setup
  4. return if !Setting.find_by(name: 'system_init_done')
  5. drop_table :ticket_time_accounting
  6. create_table :ticket_time_accountings do |t|
  7. t.references :ticket, null: false
  8. t.references :ticket_article, null: true
  9. t.column :time_unit, :decimal, precision: 6, scale: 2, null: false
  10. t.column :created_by_id, :integer, null: false
  11. t.timestamps limit: 3, null: false
  12. end
  13. add_index :ticket_time_accountings, [:ticket_id]
  14. add_index :ticket_time_accountings, [:ticket_article_id]
  15. add_index :ticket_time_accountings, [:created_by_id]
  16. add_index :ticket_time_accountings, [:time_unit]
  17. add_column :tickets, :time_unit, :decimal, precision: 6, scale: 2, null: true
  18. add_index :tickets, [:time_unit]
  19. Cache.clear
  20. end
  21. end