summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
authorgitlabhq <m@gitlabhq.com>2011-10-28 12:22:09 +0300
committergitlabhq <m@gitlabhq.com>2011-10-28 12:22:09 +0300
commita0171813391c8226802621a710798e376fea2f1e (patch)
tree8022e71a0661d670ef564e576ff452f073eb55ab /db/migrate
parent56d9761844b2665e9e48d50f15f7ac3a63d60618 (diff)
downloadgitlab-ce-a0171813391c8226802621a710798e376fea2f1e.tar.gz
new issue format
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20111027152724_issue_conten_to_note.rb27
1 files changed, 25 insertions, 2 deletions
diff --git a/db/migrate/20111027152724_issue_conten_to_note.rb b/db/migrate/20111027152724_issue_conten_to_note.rb
index 15d96c30b43..c151a9317ff 100644
--- a/db/migrate/20111027152724_issue_conten_to_note.rb
+++ b/db/migrate/20111027152724_issue_conten_to_note.rb
@@ -1,8 +1,31 @@
class IssueContenToNote < ActiveRecord::Migration
def up
- raise "Not ready"
+ puts "Issue content is deprecated -> move to notes"
Issue.find_each(:batch_size => 100) do |issue|
-
+ 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"
end
end