Merge branch 'new_issue' into dev
This commit is contained in:
commit
3fa770dd10
12 changed files with 84 additions and 18 deletions
34
db/migrate/20111027152724_issue_conten_to_note.rb
Normal file
34
db/migrate/20111027152724_issue_conten_to_note.rb
Normal file
|
@ -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
|
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue