This method is only available on newer versions.
The first available version (v7.2.3) is shown here.
set_constraints(deferred, *constraints)
public
Set when constraints will be checked for the current transaction.
Not passing any specific constraint names will set the value for all
deferrable constraints.
deferred
Valid values are :deferred or :immediate.
See www.postgresql.org/docs/current/sql-set-constraints.html
# File activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb, line 148
def set_constraints(deferred, *constraints)
unless %[deferred immediate].include?(deferred)
raise ArgumentError, "deferred must be :deferred or :immediate"
end
constraints = if constraints.empty?
"ALL"
else
constraints.map { |c| quote_table_name(c) }.join(", ")
end
execute("SET CONSTRAINTS #{constraints} #{deferred.to_s.upcase}")
end