add Link, Event classes to migration and use find_each

Albert Sun vor 10 Jahren
Ursprung
Commit
2ea5ad24c4
1 geänderte Dateien mit 4 neuen Zeilen und 1 gelöschten Zeilen
  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 @@
1 1
 class AddEventIdAtCreationToLinks < ActiveRecord::Migration
2
+  class Link < ActiveRecord::Base; end
3
+  class Event < ActiveRecord::Base; end
4
+
2 5
   def up
3 6
     add_column :links, :event_id_at_creation, :integer, :null => false, :default => 0
4 7
 
5
-    Link.all.each do |link|
8
+    Link.all.find_each do |link|
6 9
       last_event_id = execute(
7 10
         <<-SQL
8 11
           SELECT #{ActiveRecord::Base.connection.quote_column_name('id')}