20151019000001_create_report.rb 964 B

1234567891011121314151617181920212223242526272829
  1. class CreateReport < ActiveRecord::Migration
  2. def up
  3. create_table :report_profiles do |t|
  4. t.column :name, :string, limit: 150, null: true
  5. t.column :condition, :string, limit: 6000, null: true
  6. t.column :active, :boolean, null: false, default: true
  7. t.column :updated_by_id, :integer, null: false
  8. t.column :created_by_id, :integer, null: false
  9. t.timestamps null: false
  10. end
  11. add_index :report_profiles, [:name], unique: true
  12. # return if it's a new setup
  13. return if !Setting.find_by(name: 'system_init_done')
  14. Report::Profile.create_if_not_exists(
  15. name: '-all-',
  16. condition: {},
  17. active: true,
  18. updated_by_id: 1,
  19. created_by_id: 1,
  20. )
  21. Role.create_if_not_exists(name: 'Report', created_by_id: 1, updated_by_id: 1)
  22. end
  23. def down
  24. drop_table :report_profiles
  25. end
  26. end