2016-03-17 17:33:38 +01:00
|
|
|
class CerfaHaveUser < ActiveRecord::Migration
|
2018-03-06 13:44:29 +01:00
|
|
|
class Cerfa < ApplicationRecord
|
2016-03-17 17:33:38 +01:00
|
|
|
belongs_to :dossier
|
|
|
|
end
|
|
|
|
|
2018-03-06 13:44:29 +01:00
|
|
|
class Dossier < ApplicationRecord
|
2016-03-17 17:33:38 +01:00
|
|
|
belongs_to :user
|
|
|
|
end
|
|
|
|
|
2018-03-06 13:44:29 +01:00
|
|
|
class User < ApplicationRecord
|
2016-03-17 17:33:38 +01:00
|
|
|
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
|