class ArtistBelongsToUser < ActiveRecord::Migration
def up
- add_column :artists, :user_id, :integer, :null => false, :default => 0
- add_column :artists, :provider, :integer, :null => false, :default => 0
+ add_column :artists, :user_id, :integer
+ add_column :artists, :provider_id, :integer
Artist.find(:all).each do |artist|
if artist.author_id
artist.user_id = Author.find(artist.author_id).user_id
else
- artist.provider = 1
+ par = ProviderArtist.find_by_demanders_artist_id(artist.id)
+ artist.provider = par.provider_id
end
artist.save!
end