2018-11-08 12:53:41 +00:00
|
|
|
# Fixes issue #2333 - Object country already exists
|
|
|
|
# The country column already exists in the database, but there is no corresponding ObjectManager::Attribute for it
|
|
|
|
# This migration adds the User.country attribute if and only if it does not exist already
|
|
|
|
class AddCountryAttributeToUsers < ActiveRecord::Migration[5.1]
|
|
|
|
def up
|
|
|
|
# return if it's a new setup
|
|
|
|
return if !Setting.find_by(name: 'system_init_done')
|
|
|
|
|
|
|
|
# return if the country attribute already exists
|
|
|
|
current_country_attribute = ObjectManager::Attribute.find_by(object_lookup_id: ObjectLookup.by_name('User'), name: 'country')
|
|
|
|
return if current_country_attribute.present?
|
|
|
|
|
|
|
|
ObjectManager::Attribute.add(
|
2018-12-19 17:31:51 +00:00
|
|
|
force: true,
|
|
|
|
object: 'User',
|
|
|
|
name: 'country',
|
|
|
|
display: 'Country',
|
|
|
|
data_type: 'input',
|
|
|
|
data_option: {
|
|
|
|
type: 'text',
|
|
|
|
maxlength: 100,
|
|
|
|
null: true,
|
2018-11-08 12:53:41 +00:00
|
|
|
item_class: 'formGroup--halfSize',
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
editable: true,
|
|
|
|
active: false,
|
|
|
|
screens: {
|
|
|
|
signup: {},
|
|
|
|
invite_agent: {},
|
2018-11-08 12:53:41 +00:00
|
|
|
invite_customer: {},
|
2018-12-19 17:31:51 +00:00
|
|
|
edit: {
|
2018-11-08 12:53:41 +00:00
|
|
|
'-all-' => {
|
|
|
|
null: true,
|
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
view: {
|
2018-11-08 12:53:41 +00:00
|
|
|
'-all-' => {
|
|
|
|
shown: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
to_create: false,
|
|
|
|
to_migrate: false,
|
|
|
|
to_delete: false,
|
|
|
|
position: 1325,
|
2018-11-08 12:53:41 +00:00
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|