gitlab-org--gitlab-foss/db/migrate/20111027152724_issue_conten_to_note.rb

35 lines
780 B
Ruby
Raw Normal View History

2011-10-27 11:46:30 -04:00
class IssueContenToNote < ActiveRecord::Migration
def up
2011-10-28 05:22:09 -04:00
puts "Issue content is deprecated -> move to notes"
2011-10-27 11:46:30 -04:00
Issue.find_each(:batch_size => 100) do |issue|
2011-10-28 05:22:09 -04: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 03:34:30 -05:00
else
2011-10-28 05:22:09 -04:00
print "F"
end
end
total = Issue.where("content is not null").count
2011-11-15 03:34:30 -05:00
if total > 0
puts "content of #{total} issues were not migrated"
else
2011-10-28 05:22:09 -04:00
puts "Done"
2011-10-27 11:46:30 -04:00
end
end
def down
end
end