2022-07-23 23:45:48 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
namespace :gitlab do
|
|
|
|
namespace :db do
|
|
|
|
desc "GitLab | DB | Install prevent write triggers on all databases"
|
|
|
|
task lock_writes: [:environment, 'gitlab:db:validate_config'] do
|
2023-04-23 21:23:45 +05:30
|
|
|
logger = Logger.new($stdout)
|
|
|
|
logger.level = Gitlab::Utils.to_boolean(ENV['VERBOSE']) ? Logger::INFO : Logger::WARN
|
|
|
|
Gitlab::Database::TablesLocker.new(
|
|
|
|
logger: logger,
|
|
|
|
dry_run: Gitlab::Utils.to_boolean(ENV['DRY_RUN'], default: false)
|
|
|
|
).lock_writes
|
2022-07-23 23:45:48 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
desc "GitLab | DB | Remove all triggers that prevents writes from all databases"
|
|
|
|
task unlock_writes: :environment do
|
2023-04-23 21:23:45 +05:30
|
|
|
logger = Logger.new($stdout)
|
|
|
|
logger.level = Gitlab::Utils.to_boolean(ENV['VERBOSE']) ? Logger::INFO : Logger::WARN
|
|
|
|
Gitlab::Database::TablesLocker.new(
|
|
|
|
logger: logger,
|
|
|
|
dry_run: Gitlab::Utils.to_boolean(ENV['DRY_RUN'], default: false)
|
|
|
|
).unlock_writes
|
2022-07-23 23:45:48 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|