Browse Source

add Link, Event classes to migration and use find_each

Albert Sun 11 years ago
parent
commit
2ea5ad24c4
1 changed files with 4 additions and 1 deletions
  1. 4 1
      db/migrate/20140213053001_add_event_id_at_creation_to_links.rb

+ 4 - 1
db/migrate/20140213053001_add_event_id_at_creation_to_links.rb

@@ -1,8 +1,11 @@
 class AddEventIdAtCreationToLinks < ActiveRecord::Migration
+  class Link < ActiveRecord::Base; end
+  class Event < ActiveRecord::Base; end
+
   def up
     add_column :links, :event_id_at_creation, :integer, :null => false, :default => 0
 
-    Link.all.each do |link|
+    Link.all.find_each do |link|
       last_event_id = execute(
         <<-SQL
           SELECT #{ActiveRecord::Base.connection.quote_column_name('id')}