demarches-normaliennes/db/migrate/20160317153115_cerfa_have_user.rb
2017-06-13 10:35:32 +02:00

21 lines
394 B
Ruby

class CerfaHaveUser < ActiveRecord::Migration
class Cerfa < ActiveRecord::Base
belongs_to :dossier
end
class Dossier < ActiveRecord::Base
belongs_to :user
end
class User < ActiveRecord::Base
end
def change
add_reference :cerfas, :user, references: :users
Cerfa.all.each do |cerfa|
cerfa.user_id = cerfa.dossier.user.id
cerfa.save
end
end
end