Commit 6ea6cdd7 authored by Andreas Brandl's avatar Andreas Brandl Committed by Adam Hegyi

Use migration level lock-retries

parent 30cce575
...@@ -41,6 +41,8 @@ Settings are not cascading by default. To define a cascading setting, take the f ...@@ -41,6 +41,8 @@ Settings are not cascading by default. To define a cascading setting, take the f
class AddDelayedProjectRemovalCascadingSetting < Gitlab::Database::Migration[1.0] class AddDelayedProjectRemovalCascadingSetting < Gitlab::Database::Migration[1.0]
include Gitlab::Database::MigrationHelpers::CascadingNamespaceSettings include Gitlab::Database::MigrationHelpers::CascadingNamespaceSettings
enable_lock_retries!
def up def up
add_cascading_namespace_setting :delayed_project_removal, :boolean, default: false, null: false add_cascading_namespace_setting :delayed_project_removal, :boolean, default: false, null: false
end end
......
...@@ -31,10 +31,8 @@ module Gitlab ...@@ -31,10 +31,8 @@ module Gitlab
namespace_options = options.merge(null: true, default: nil) namespace_options = options.merge(null: true, default: nil)
with_lock_retries do add_column(:namespace_settings, setting_name, type, namespace_options)
add_column(:namespace_settings, setting_name, type, namespace_options) add_column(:namespace_settings, lock_column_name, :boolean, default: false, null: false)
add_column(:namespace_settings, lock_column_name, :boolean, default: false, null: false)
end
add_column(:application_settings, setting_name, type, options) add_column(:application_settings, setting_name, type, options)
add_column(:application_settings, lock_column_name, :boolean, default: false, null: false) add_column(:application_settings, lock_column_name, :boolean, default: false, null: false)
...@@ -43,10 +41,8 @@ module Gitlab ...@@ -43,10 +41,8 @@ module Gitlab
def remove_cascading_namespace_setting(setting_name) def remove_cascading_namespace_setting(setting_name)
lock_column_name = "lock_#{setting_name}".to_sym lock_column_name = "lock_#{setting_name}".to_sym
with_lock_retries do remove_column(:namespace_settings, setting_name) if column_exists?(:namespace_settings, setting_name)
remove_column(:namespace_settings, setting_name) if column_exists?(:namespace_settings, setting_name) remove_column(:namespace_settings, lock_column_name) if column_exists?(:namespace_settings, lock_column_name)
remove_column(:namespace_settings, lock_column_name) if column_exists?(:namespace_settings, lock_column_name)
end
remove_column(:application_settings, setting_name) if column_exists?(:application_settings, setting_name) remove_column(:application_settings, setting_name) if column_exists?(:application_settings, setting_name)
remove_column(:application_settings, lock_column_name) if column_exists?(:application_settings, lock_column_name) remove_column(:application_settings, lock_column_name) if column_exists?(:application_settings, lock_column_name)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment