Followup for commit b1b137bb0d
- verify if object manager attribute exists for user only (not locale for any other object).
This commit is contained in:
parent
ffd7ae99b1
commit
04c1cf2fb9
1 changed files with 18 additions and 2 deletions
|
@ -4,13 +4,29 @@ class RenameLocaleOnUsers < ActiveRecord::Migration[5.1]
|
||||||
return if ActiveRecord::Base.connection.columns('users').map(&:name).exclude?('locale')
|
return if ActiveRecord::Base.connection.columns('users').map(&:name).exclude?('locale')
|
||||||
|
|
||||||
ActiveRecord::Migration.rename_column(:users, :locale, :_locale)
|
ActiveRecord::Migration.rename_column(:users, :locale, :_locale)
|
||||||
ObjectManager::Attribute.find_by(name: 'locale').update(name: '_locale')
|
User.reset_column_information
|
||||||
|
|
||||||
|
attribute = ObjectManager::Attribute.get(
|
||||||
|
object: 'User',
|
||||||
|
name: 'locale',
|
||||||
|
)
|
||||||
|
return if !attribute
|
||||||
|
|
||||||
|
attribute.update(name: '_locale')
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
return if ActiveRecord::Base.connection.columns('users').map(&:name).exclude?('_locale')
|
return if ActiveRecord::Base.connection.columns('users').map(&:name).exclude?('_locale')
|
||||||
|
|
||||||
ActiveRecord::Migration.rename_column(:users, :_locale, :locale)
|
ActiveRecord::Migration.rename_column(:users, :_locale, :locale)
|
||||||
ObjectManager::Attribute.find_by(name: '_locale').update(name: 'locale')
|
User.reset_column_information
|
||||||
|
|
||||||
|
attribute = ObjectManager::Attribute.get(
|
||||||
|
object: 'User',
|
||||||
|
name: '_locale',
|
||||||
|
)
|
||||||
|
return if !attribute
|
||||||
|
|
||||||
|
attribute.update(name: 'locale')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue