2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module Gitlab
|
|
|
|
module Database
|
|
|
|
# Module that can be injected into a ActiveRecord::Relation to make it
|
|
|
|
# read-only.
|
|
|
|
module ReadOnlyRelation
|
|
|
|
[:delete, :delete_all, :update, :update_all].each do |method|
|
|
|
|
define_method(method) do |*args|
|
|
|
|
raise(
|
|
|
|
ActiveRecord::ReadOnlyRecord,
|
|
|
|
"This relation is marked as read-only"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|