OSDN Git Service

merge v06sheet
[pettanr/pettanr.git] / db / migrate / 20130911043458_copy_to_scroll.rb
diff --git a/db/migrate/20130911043458_copy_to_scroll.rb b/db/migrate/20130911043458_copy_to_scroll.rb
new file mode 100644 (file)
index 0000000..37f9f54
--- /dev/null
@@ -0,0 +1,23 @@
+require Rails.root + 'config/environment'
+class CopyToScroll < ActiveRecord::Migration
+  def up
+    ::Comic.find(:all).each do |i|
+      attr = i.attributes
+      attr.delete 'id'
+      ::Scroll.create! attr
+    end
+    ::Story.find(:all).each do |i|
+      attr = i.attributes
+      attr.delete 'id'
+      attr.delete 'x'
+      attr.delete 'y'
+      attr.delete 'z'
+      attr['scroll_id'] = attr['comic_id']
+      attr.delete 'comic_id'
+      ::ScrollPanel.create! attr
+    end
+  end
+
+  def down
+  end
+end