2016-03-17 17:33:38 +01:00
|
|
|
class PieceJustificativeHaveUser < ActiveRecord::Migration
|
2018-03-06 13:44:29 +01:00
|
|
|
class PieceJustificative < 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 :pieces_justificatives, :user, references: :users
|
|
|
|
|
|
|
|
PieceJustificative.all.each do |piece_justificative|
|
|
|
|
piece_justificative.user_id = piece_justificative.dossier.user.id
|
|
|
|
piece_justificative.save
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|