Handle not ready repos
[gitorious.git] / db / migrate / 20090827081458_migration_merge_request_proposals_to_summery.rb
blob69fe0708370acad2e2ec4d3298fa5b2bfbd8302d
1 # encoding: utf-8
3 class MigrationMergeRequestProposalsToSummery < ActiveRecord::Migration
4   def self.up
5     transaction do
6       MergeRequest.all.each do |mr|
7         if mr.proposal.blank?
8           mr.summary = "..."
9           mr.save!
10           next
11         end
12         mr.summary = mr.proposal.encode("utf-8",
13             :undef => :replace, :invalid => :replace, :replace => "?")[0..75]
14         mr.summary << '...' if mr.proposal.length > 75
15         mr.save!
16       end
17     end
18   end
20   def self.down
21   end
22 end