avoid overwriting default setting value

pull/10016/head
ulferts 3 years ago
parent 89cfee203f
commit 407e5ffa1e
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 7
      app/models/setting.rb
  2. 28
      db/migrate/20190618115620_fix_available_languages.rb
  3. 2
      db/migrate/20200903064009_enable_current_project_custom_fields_columns.rb

@ -29,6 +29,9 @@
#++
class Setting < ApplicationRecord
extend Callbacks
extend Aliases
DATE_FORMATS = [
'%Y-%m-%d',
'%d/%m/%Y',
@ -338,8 +341,4 @@ class Setting < ApplicationRecord
value
end
end
extend Callbacks
extend Aliases
end

@ -1,12 +1,14 @@
class FixAvailableLanguages < ActiveRecord::Migration[5.2]
def up
Setting.reset_column_information
if Setting.exists?(name: 'available_languages')
Setting.reset_column_information
Setting.available_languages = Setting.available_languages.map do |lang|
if lang == 'zh'
'zh-CN'
else
lang
Setting.available_languages = Setting.available_languages.map do |lang|
if lang == 'zh'
'zh-CN'
else
lang
end
end
end
@ -14,13 +16,15 @@ class FixAvailableLanguages < ActiveRecord::Migration[5.2]
end
def down
Setting.reset_column_information
if Setting.exists?(name: 'available_languages')
Setting.reset_column_information
Setting.available_languages = Setting.available_languages.map do |lang|
if lang == 'zh-CN'
'zh'
else
lang
Setting.available_languages = Setting.available_languages.map do |lang|
if lang == 'zh-CN'
'zh'
else
lang
end
end
end

@ -1,5 +1,7 @@
class EnableCurrentProjectCustomFieldsColumns < ActiveRecord::Migration[6.0]
def up
return unless Setting.exists?(name: 'enabled_projects_column')
columns = Setting.enabled_projects_columns
cf_columns = ProjectCustomField.pluck(:id).map { |id| "cf_#{id}" }

Loading…
Cancel
Save