OSDN Git Service

rails upgrade to 4
[pettanr/pettanr.git] / db / migrate / 20120618023403_connect_story.rb
index 1806125..efae69d 100644 (file)
@@ -1,12 +1,11 @@
 class ConnectStory < ActiveRecord::Migration
   def up
-    pn = Panel.find :all
-    pn.each do |i|
+    pn = Panel.find_each do |i|
       c = i.comic_id
       t = i.t
       a = i.author_id
       s = i.id
-      st = Story.find(:first, :conditions => ['comic_id = ? and panel_id = ? and t = ?', c, s, t])
+      st = Story.where(['comic_id = ? and panel_id = ? and t = ?', c, s, t]).first
       st = Story.new(:comic_id => c, :panel_id => s, :t => t) unless st
       st.author_id = a
       st.save!
@@ -22,8 +21,7 @@ class ConnectStory < ActiveRecord::Migration
     add_column :panels, :comic_id, :integer, :null => false, :default => 0
     add_column :panels, :t, :integer, :null => false, :default => 0
     remove_column :panels, :publish
-    st = Story.find :all
-    st.each do |i|
+    st = Story.find_each do |i|
       c = i.comic_id
       t = i.t
       pn = Panel.find(i.panel_id)