20161112000001_organization_domain_based_assignment.rb 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. class OrganizationDomainBasedAssignment < ActiveRecord::Migration
  2. def up
  3. # return if it's a new setup
  4. return if !Setting.find_by(name: 'system_init_done')
  5. add_column :organizations, :domain, :string, limit: 250, null: true, default: ''
  6. add_column :organizations, :domain_assignment, :boolean, null: false, default: false
  7. add_index :organizations, [:domain]
  8. ObjectManager::Attribute.add(
  9. force: true,
  10. object: 'Organization',
  11. name: 'domain_assignment',
  12. display: 'Domain based assignment',
  13. data_type: 'boolean',
  14. data_option: {
  15. null: true,
  16. default: false,
  17. note: 'Assign Users based on users domain.',
  18. item_class: 'formGroup--halfSize',
  19. options: {
  20. true: 'yes',
  21. false: 'no',
  22. },
  23. translate: true,
  24. },
  25. editable: false,
  26. active: true,
  27. screens: {
  28. edit: {
  29. Admin: {
  30. null: false,
  31. },
  32. },
  33. view: {
  34. '-all-' => {
  35. shown: true,
  36. },
  37. },
  38. },
  39. to_create: false,
  40. to_migrate: false,
  41. to_delete: false,
  42. position: 1410,
  43. updated_by_id: 1,
  44. created_by_id: 1,
  45. )
  46. ObjectManager::Attribute.add(
  47. force: true,
  48. object: 'Organization',
  49. name: 'domain',
  50. display: 'Domain',
  51. data_type: 'input',
  52. data_option: {
  53. type: 'text',
  54. maxlength: 150,
  55. null: true,
  56. item_class: 'formGroup--halfSize',
  57. },
  58. editable: false,
  59. active: true,
  60. screens: {
  61. edit: {
  62. '-all-' => {
  63. null: true,
  64. },
  65. },
  66. view: {
  67. '-all-' => {
  68. shown: true,
  69. },
  70. },
  71. },
  72. to_create: false,
  73. to_migrate: false,
  74. to_delete: false,
  75. position: 1420,
  76. updated_by_id: 1,
  77. created_by_id: 1,
  78. )
  79. Cache.clear
  80. end
  81. end