summaryrefslogtreecommitdiffstats
path: root/db/migrate/20130911193200_remove_eols_from_attachments_filename.rb
blob: 8be7a27b4b733274775c4b45eaa73c66a50294e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# frozen_string_literal: false

class RemoveEolsFromAttachmentsFilename < ActiveRecord::Migration[4.2]
  def up
    Attachment.where("filename like ? or filename like ?", "%\r%", "%\n%").each do |attachment|
      filename = attachment.filename.to_s.tr("\r\n", "_")
      Attachment.where(:id => attachment.id).update_all(:filename => filename)
    end
  end

  def down
    # nop
  end
end