Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

avoid overwriting default setting value

ulferts407e5ffa1e10
diff --git a/app/models/setting.rb b/app/models/setting.rb
index f63cc9c0775..b4644810b53 100644
--- a/app/models/setting.rb
+++ b/app/models/setting.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
diff --git a/db/migrate/20190618115620_fix_available_languages.rb b/db/migrate/20190618115620_fix_available_languages.rb
index dba5261e00c..aad7954ebeb 100644
--- a/db/migrate/20190618115620_fix_available_languages.rb
+++ b/db/migrate/20190618115620_fix_available_languages.rb
@@ -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
diff --git a/db/migrate/20200903064009_enable_current_project_custom_fields_columns.rb b/db/migrate/20200903064009_enable_current_project_custom_fields_columns.rb
index 4b3540b3025..a2e32f52895 100644
--- a/db/migrate/20200903064009_enable_current_project_custom_fields_columns.rb
+++ b/db/migrate/20200903064009_enable_current_project_custom_fields_columns.rb
@@ -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}" }