ValidationEmergency.with_deleted.where(
code: 'aml_validation_failed',
service_name: 'ComplyAdvantage', service_type: nil).each do |e|
e.update_attributes(
{
service_type: 'Screening',
service_id: e.message.split(', ').last.split(' => ').last.to_i
}, without_protection: true
)
end
目前为止我所拥有的(在@fanta的评论之后编辑)
ActiveRecord::Base.connection.execute("
UPDATE validation_emergencies
SET
service_type = 'Screening',
service_id = (
CAST ( array_upper(string_to_array(message, ' => '), 1) AS INTEGER )
)
WHERE
code = 'aml_validation_failed'
AND
service_name = 'ComplyAdvantage'
AND
service_type IS NULL"
)
请告知。谢谢您。