Fix ApplicationSetting development seed
It could happen that there's a cached (in Redis) ApplicationSetting record, and calling `Gitlab::CurrentSettings.current_application_settings` only returns it instead of creating a new DB record, which makes the `ApplicationSetting.current_without_cache.update!` call fail. Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
parent
6c8a13da33
commit
22c1c9805b
|
@ -259,7 +259,9 @@ class ApplicationSetting < ApplicationRecord
|
|||
after_commit :expire_performance_bar_allowed_user_ids_cache, if: -> { previous_changes.key?('performance_bar_allowed_group_id') }
|
||||
|
||||
def self.create_from_defaults
|
||||
super
|
||||
transaction(requires_new: true) do
|
||||
super
|
||||
end
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
# We already have an ApplicationSetting record, so just return it.
|
||||
current_without_cache
|
||||
|
|
|
@ -159,8 +159,8 @@ module Projects
|
|||
log_message << " Project ID: #{@project.id}" if @project&.id
|
||||
Rails.logger.error(log_message)
|
||||
|
||||
if @project
|
||||
@project.import_state.mark_as_failed(message) if @project.persisted? && @project.import?
|
||||
if @project && @project.persisted? && @project.import_state
|
||||
@project.import_state.mark_as_failed(message)
|
||||
end
|
||||
|
||||
@project
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
puts "Creating the default ApplicationSetting record.".color(:green)
|
||||
Gitlab::CurrentSettings.current_application_settings
|
||||
ApplicationSetting.create_from_defaults
|
||||
|
||||
# Details https://gitlab.com/gitlab-org/gitlab-ce/issues/46241
|
||||
puts "Enable hashed storage for every new projects.".color(:green)
|
||||
|
|
Loading…
Reference in New Issue