--- /dev/null
+class ConnectStory < ActiveRecord::Migration
+ def up
+ pn = Panel.find :all
+ pn.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.new(:comic_id => c, :panel_id => s, :t => t) unless st
+ st.author_id = a
+ st.save!
+ end
+ remove_column :comics, :editable
+ remove_column :panels, :comic_id
+ remove_column :panels, :t
+ add_column :panels, :publish, :integer, :null => false, :default => 0
+ end
+
+ def down
+ add_column :comics, :editable, :integer, :null => false, :default => 0
+ 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|
+ c = i.comic_id
+ t = i.t
+ pn = Panel.find(i.panel_id)
+ pn.t = t
+ pn.comic_id = c
+ pn.save!
+ end
+ end
+end