From e353e89c6df5e88d7f3bd43df96c7b6594358565 Mon Sep 17 00:00:00 2001 From: Muhammad Nuzaihan Bin Kamal Luddin Date: Tue, 3 Oct 2017 02:28:27 +0800 Subject: [PATCH] =?UTF-8?q?change=20character=20length=20limit=20in=20"not?= =?UTF-8?q?e"=20column=20in=20both=20organizations=20=E2=80=A6=20(#1497)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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. --- db/migrate/20120101000001_create_base.rb | 4 ++-- ..._char_limit_for_users_and_organizations.rb | 20 +++++++++++++++++++ db/seeds/object_manager_attributes.rb | 4 ++-- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20171002091043_change_note_char_limit_for_users_and_organizations.rb diff --git a/db/migrate/20120101000001_create_base.rb b/db/migrate/20120101000001_create_base.rb index 0c3f16752..ea1212388 100644 --- a/db/migrate/20120101000001_create_base.rb +++ b/db/migrate/20120101000001_create_base.rb @@ -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 diff --git a/db/migrate/20171002091043_change_note_char_limit_for_users_and_organizations.rb b/db/migrate/20171002091043_change_note_char_limit_for_users_and_organizations.rb new file mode 100644 index 000000000..91d64f89b --- /dev/null +++ b/db/migrate/20171002091043_change_note_char_limit_for_users_and_organizations.rb @@ -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 diff --git a/db/seeds/object_manager_attributes.rb b/db/seeds/object_manager_attributes.rb index e622a82e8..41ab17826 100644 --- a/db/seeds/object_manager_attributes.rb +++ b/db/seeds/object_manager_attributes.rb @@ -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.', },