summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorgitlabhq <m@gitlabhq.com>2011-10-28 12:26:25 +0300
committergitlabhq <m@gitlabhq.com>2011-10-28 12:26:25 +0300
commit3fa770dd107d01c29741032703c3f69b9ff3f072 (patch)
tree2e0274dfda234771ea75ab143cf2a64501b36e01 /db
parent89fa800e28e4b740b9de2e526f0f4354d8310ecb (diff)
parenta0171813391c8226802621a710798e376fea2f1e (diff)
downloadgitlab-ce-3fa770dd107d01c29741032703c3f69b9ff3f072.tar.gz
Merge branch 'new_issue' into dev
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20111027152724_issue_conten_to_note.rb34
-rw-r--r--db/schema.rb2
2 files changed, 35 insertions, 1 deletions
diff --git a/db/migrate/20111027152724_issue_conten_to_note.rb b/db/migrate/20111027152724_issue_conten_to_note.rb
new file mode 100644
index 00000000000..c151a9317ff
--- /dev/null
+++ b/db/migrate/20111027152724_issue_conten_to_note.rb
@@ -0,0 +1,34 @@
+class IssueContenToNote < ActiveRecord::Migration
+ def up
+ 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
+
+ def down
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 1ac90a9b400..13c4db0cc49 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20111027142641) do
+ActiveRecord::Schema.define(:version => 20111027152724) do
create_table "issues", :force => true do |t|
t.string "title"