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!
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)