change character length limit in "note" column in both organizations … (#1497)

* Change character length limit in "note" column in both organizations and users #1495.

* Update config seed to set maximum 5000 characters for validation, update base migration for new installs and migrations for installed instances #1495.
This commit is contained in:
Muhammad Nuzaihan Bin Kamal Luddin 2017-10-03 02:28:27 +08:00 committed by Martin Edenhofer
parent 38ef22e4e5
commit e353e89c6d
3 changed files with 24 additions and 4 deletions

View file

@ -36,7 +36,7 @@ class CreateBase < ActiveRecord::Migration[4.2]
t.boolean :vip, default: false
t.boolean :verified, null: false, default: false
t.boolean :active, null: false, default: true
t.string :note, limit: 250, null: true, default: ''
t.string :note, limit: 5000, null: true, default: ''
t.timestamp :last_login, limit: 3, null: true
t.string :source, limit: 200, null: true
t.integer :login_failed, null: false, default: 0
@ -147,7 +147,7 @@ class CreateBase < ActiveRecord::Migration[4.2]
t.string :domain, limit: 250, null: true, default: ''
t.boolean :domain_assignment, null: false, default: false
t.boolean :active, null: false, default: true
t.string :note, limit: 250, null: true, default: ''
t.string :note, limit: 5000, null: true, default: ''
t.integer :updated_by_id, null: false
t.integer :created_by_id, null: false
t.timestamps limit: 3, null: false

View file

@ -0,0 +1,20 @@
class ChangeNoteCharLimitForUsersAndOrganizations < ActiveRecord::Migration[5.1]
def up
# return if it's a new setup to avoid running the migration
return if !Setting.find_by(name: 'system_init_done')
change_column :organizations, :note, :string, limit: 5000
change_column :users, :note, :string, limit: 5000
object_id = ObjectLookup.by_name('User')
attribute = ObjectManager::Attribute.find_by(object_lookup_id: object_id, name: 'note')
attribute.data_option[:maxlength] = 5000
attribute.save!
object_id = ObjectLookup.by_name('Organization')
attribute = ObjectManager::Attribute.find_by(object_lookup_id: object_id, name: 'note')
attribute.data_option[:maxlength] = 5000
attribute.save!
end
end

View file

@ -1077,7 +1077,7 @@ ObjectManager::Attribute.add(
data_type: 'richtext',
data_option: {
type: 'text',
maxlength: 250,
maxlength: 5000,
null: true,
note: 'Notes are visible to agents only, never to customers.',
},
@ -1329,7 +1329,7 @@ ObjectManager::Attribute.add(
data_type: 'richtext',
data_option: {
type: 'text',
maxlength: 250,
maxlength: 5000,
null: true,
note: 'Notes are visible to agents only, never to customers.',
},