Add migration to retroactively convert HttpLogs to UTF8

This commit is contained in:
Ryan Lue 2018-07-11 17:01:54 +08:00
parent 680a560c06
commit f041fef7ff

View file

@ -0,0 +1,11 @@
class Issue2100Utf8EncodeHttpLogs < ActiveRecord::Migration[5.1]
def up
HttpLog.where('request LIKE :enctag OR response LIKE :enctag', enctag: '%content: !binary |%')
.limit(100_000)
.order(created_at: :desc)
.find_each do |log|
log.update(request: log.request.transform_values(&:utf8_encode),
response: log.response.transform_values(&:utf8_encode))
end
end
end