view .svn/pristine/14/144d87a484de2d989cccbe9e992e92ab12eacca5.svn-base @ 985:acaa61dde68b bug_522

Allow file attachment to wrap to avoid extra-wide text field
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Fri, 26 Oct 2012 17:18:52 +0100
parents cbb26bc654de
children
line wrap: on
line source
class PopulateChangesetsUserId < ActiveRecord::Migration
  def self.up
    committers = Changeset.connection.select_values("SELECT DISTINCT committer FROM #{Changeset.table_name}")
    committers.each do |committer|
      next if committer.blank?
      if committer.strip =~ /^([^<]+)(<(.*)>)?$/
        username, email = $1.strip, $3
        u = User.find_by_login(username)
        u ||= User.find_by_mail(email) unless email.blank?
        Changeset.update_all("user_id = #{u.id}", ["committer = ?", committer]) unless u.nil?
      end
    end
  end

  def self.down
    Changeset.update_all('user_id = NULL')
  end
end