gitlabhq/db/migrate/20111027152724_issue_conten_to_note.rb

35 lines
780 B
Ruby
Raw Normal View History

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 "."
2011-11-15 09:34:30 +01:00
else
2011-10-28 11:22:09 +02:00
print "F"
end
end
total = Issue.where("content is not null").count
2011-11-15 09:34:30 +01:00
if total > 0
puts "content of #{total} issues were not migrated"
else
2011-10-28 11:22:09 +02:00
puts "Done"
2011-10-27 17:46:30 +02:00
end
end
def down
end
end