2011-10-27 17:46:30 +02:00
|
|
|
class IssueContenToNote < ActiveRecord::Migration
|
|
|
|
def up
|
2011-10-28 11:22:09 +02:00
|
|
|
puts "Issue content is deprecated -> move to notes"
|
2011-10-27 17:46:30 +02:00
|
|
|
Issue.find_each(:batch_size => 100) do |issue|
|
2011-10-28 11:22:09 +02:00
|
|
|
next if issue.content.blank?
|
|
|
|
note = Note.new(
|
|
|
|
:note => issue.content,
|
|
|
|
:project_id => issue.project_id,
|
|
|
|
:noteable => issue,
|
|
|
|
:created_at => issue.created_at,
|
|
|
|
:updated_at => issue.created_at
|
|
|
|
)
|
|
|
|
note.author_id = issue.author_id
|
|
|
|
|
|
|
|
if note.save
|
|
|
|
issue.update_attributes(:content => nil)
|
|
|
|
print "."
|
|
|
|
else
|
|
|
|
print "F"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
total = Issue.where("content is not null").count
|
|
|
|
|
|
|
|
if total > 0
|
|
|
|
puts "content of #{total} issues were not migrated"
|
|
|
|
else
|
|
|
|
puts "Done"
|
2011-10-27 17:46:30 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
end
|
|
|
|
end
|