2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2019-04-01 07:22:29 +00:00
|
|
|
class RenameLocaleOnUsers < ActiveRecord::Migration[5.1]
|
|
|
|
def up
|
2020-08-03 08:35:43 +00:00
|
|
|
return if !Setting.exists?(name: 'system_init_done')
|
2019-04-01 07:22:29 +00:00
|
|
|
return if ActiveRecord::Base.connection.columns('users').map(&:name).exclude?('locale')
|
|
|
|
|
|
|
|
ActiveRecord::Migration.rename_column(:users, :locale, :_locale)
|
2019-04-07 22:11:11 +00:00
|
|
|
User.reset_column_information
|
|
|
|
|
|
|
|
attribute = ObjectManager::Attribute.get(
|
|
|
|
object: 'User',
|
|
|
|
name: 'locale',
|
|
|
|
)
|
|
|
|
return if !attribute
|
|
|
|
|
|
|
|
attribute.update(name: '_locale')
|
2019-04-01 07:22:29 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
return if ActiveRecord::Base.connection.columns('users').map(&:name).exclude?('_locale')
|
|
|
|
|
|
|
|
ActiveRecord::Migration.rename_column(:users, :_locale, :locale)
|
2019-04-07 22:11:11 +00:00
|
|
|
User.reset_column_information
|
|
|
|
|
|
|
|
attribute = ObjectManager::Attribute.get(
|
|
|
|
object: 'User',
|
|
|
|
name: '_locale',
|
|
|
|
)
|
|
|
|
return if !attribute
|
|
|
|
|
|
|
|
attribute.update(name: 'locale')
|
2019-04-01 07:22:29 +00:00
|
|
|
end
|
|
|
|
end
|