mirror of
https://gitlab.com/gitlab-org/gitlab-foss.git
synced 2025-08-10 01:31:45 +00:00
27 lines
978 B
Ruby
27 lines
978 B
Ruby
# frozen_string_literal: true
|
|
|
|
# Extends ActiveRecord transactions with the ability of
|
|
# registering callbacks to run after the transaction completes.
|
|
#
|
|
# This feature is already implemented in Rails 7.2.0 but we are still using
|
|
# the version 7.1.x. This means that we can remove this patch while upgrading
|
|
# Rails version to 7.2.x.
|
|
#
|
|
# ApplicationRecord.transaction do
|
|
# ApplicationRecord.current_transaction.after_commit do
|
|
# SomeSidekiqJob.perform_later
|
|
# end
|
|
#
|
|
# Project.touch
|
|
# end
|
|
|
|
if ActiveRecord::ConnectionAdapters::NullTransaction.new.respond_to?(:before_commit)
|
|
raise 'This version of Rails natively supports transaction callbacks. Please remove this patch.'
|
|
end
|
|
|
|
ActiveRecord::ConnectionAdapters::NullTransaction.prepend(
|
|
GemExtensions::ActiveRecord::ConnectionAdapters::Transaction::NullTransactionCallbacks)
|
|
|
|
ActiveRecord::ConnectionAdapters::Transaction.prepend(
|
|
GemExtensions::ActiveRecord::ConnectionAdapters::Transaction::TransactionCallbacks)
|