20171002091043_change_note_char_limit_for_users_and_organizations.rb 753 B

1234567891011121314151617181920
  1. class ChangeNoteCharLimitForUsersAndOrganizations < ActiveRecord::Migration[5.1]
  2. def up
  3. # return if it's a new setup to avoid running the migration
  4. return if !Setting.find_by(name: 'system_init_done')
  5. change_column :organizations, :note, :string, limit: 5000
  6. change_column :users, :note, :string, limit: 5000
  7. object_id = ObjectLookup.by_name('User')
  8. attribute = ObjectManager::Attribute.find_by(object_lookup_id: object_id, name: 'note')
  9. attribute.data_option[:maxlength] = 5000
  10. attribute.save!
  11. object_id = ObjectLookup.by_name('Organization')
  12. attribute = ObjectManager::Attribute.find_by(object_lookup_id: object_id, name: 'note')
  13. attribute.data_option[:maxlength] = 5000
  14. attribute.save!
  15. end
  16. end