mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-16 17:26:33 +01:00
Merge pull request #130 from zoombody/bug/1351-note-migration
Reload columns before rendering notes during migration
This commit is contained in:
commit
032affb00d
1 changed files with 6 additions and 4 deletions
|
|
@ -2,10 +2,12 @@ class AddRenderedNotes < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
add_column :todos, 'rendered_notes', :text
|
add_column :todos, 'rendered_notes', :text
|
||||||
|
|
||||||
puts "-- Clearing show_from dates from completed todos"
|
Todo.reset_column_information
|
||||||
|
|
||||||
|
say "Clearing show_from dates from completed todos"
|
||||||
# clear up completed todos that have show_from set. These could have been left over from before the AASM migration
|
# clear up completed todos that have show_from set. These could have been left over from before the AASM migration
|
||||||
Todo.completed.find(:all, :conditions =>[ "NOT(show_from IS NULL)"]).each {|t| t.show_from=nil; t.save!}
|
Todo.completed.find(:all, :conditions =>[ "NOT(show_from IS NULL)"]).each {|t| t.show_from=nil; t.save!}
|
||||||
puts "-- Generating new column values from notes. This may take a while."
|
say "Generating new column values from notes. This may take a while."
|
||||||
# Call save! on each todo to force generation of rendered_todos
|
# Call save! on each todo to force generation of rendered_todos
|
||||||
i=0; max = Todo.all.count; start = Time.now
|
i=0; max = Todo.all.count; start = Time.now
|
||||||
Todo.all.each do |todo|
|
Todo.all.each do |todo|
|
||||||
|
|
@ -14,10 +16,10 @@ class AddRenderedNotes < ActiveRecord::Migration
|
||||||
if i%250==0
|
if i%250==0
|
||||||
elapsed_sec = (Time.now-start)
|
elapsed_sec = (Time.now-start)
|
||||||
remaining = (elapsed_sec / i)*(max-i)
|
remaining = (elapsed_sec / i)*(max-i)
|
||||||
puts "Progress: #{i} / #{max} (#{(i.to_f/max.to_f*100.0).floor}%) ETA=#{remaining.floor}s"
|
say "Progress: #{i} / #{max} (#{(i.to_f/max.to_f*100.0).floor}%) ETA=#{remaining.floor}s"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
puts "Done: #{i} / #{max}"
|
say "Done: #{i} / #{max}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.down
|
def self.down
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue