demarches-normaliennes/db/migrate/20160317153115_cerfa_have_user.rb
2018-03-06 17:18:44 +01:00

21 lines
391 B
Ruby

class CerfaHaveUser < ActiveRecord::Migration
class Cerfa < ApplicationRecord
belongs_to :dossier
end
class Dossier < ApplicationRecord
belongs_to :user
end
class User < ApplicationRecord
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