OSDN Git Service

rails upgrade to 4
[pettanr/pettanr.git] / db / migrate / 20131205030518_artist_belongs_to_user_data.rb
1 class ArtistBelongsToUserData < ActiveRecord::Migration
2   def up
3     Artist.find_each do |artist|
4       if artist.author_id
5         artist.user_id = Author.find(artist.author_id).user_id
6       else
7         par = ProviderArtist.find_by_demanders_artist_id(artist.id)
8         artist.provider_id = par.provider_id
9       end
10       artist.save!
11     end
12     remove_column :artists, :author_id
13   end
14
15   def down
16   end
17 end