OSDN Git Service

fix: finder
[pettanr/pettanr.git] / db / migrate / 20140520102407_rm_comic_id_on_story.rb
1 class RmComicIdOnStory < ActiveRecord::Migration
2   def up
3     add_column :stories, :author_id, :integer, :null => false, :default => 0
4     Story.all.each do |s|
5       c = Comic.find(s.comic_id)
6       ComicStory.create! :comic_id => s.comic_id, :story_id => s.id,
7         :author_id => c.author_id, :t => s.t
8       s.author_id = c.author_id
9       s.save!
10     end
11     remove_column :stories, :comic_id
12     remove_column :stories, :t
13   end
14
15   def down
16   end
17 end