Skip to content

Commit

Permalink
ISSUE #448: Correction at affiliation migration
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorMonardez committed Jan 7, 2025
1 parent beb7467 commit 2714011
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions db/migrate/20240524135850_create_affiliation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def up
end_date = start_date
# A data inicial é quando o professor recebeu algum
start_date = professor.updated_at
if professor.institution_id != institution_id && (start_date - end_date).abs > 1.month
if professor.institution_id != (institution_id && (start_date - end_date).abs > 1.month) && !professor.institution_id.nil?
# Atualiza a data caso a mudança de instituição seja maior que 1 mes
institutions << { institution_id:, start_date:, end_date: }
institution_id = professor.institution_id
Expand All @@ -34,13 +34,13 @@ def up
start_date: start_date,
end_date: end_date
)
else
elsif !professor.institution_id.nil?
affiliation.update(start_date: start_date)
end
# Se for a primeira versão do professor diminui a data de start da affiliation em um mês
if professor.paper_trail.previous_version.nil?
start_date = professor.updated_at - 1.month
affiliation.update(start_date: start_date)
binding.pry
affiliation.update(start_date: affiliation.start_date - 1.month)
end
professor = professor.paper_trail.previous_version
end
Expand Down

0 comments on commit 2714011

Please sign in to comment.