Merge pull request #5199 from tchak/fix-etablissements-dossier
Fix remaining etablissements with shared dossier
This commit is contained in:
commit
838ebfe2f1
1 changed files with 20 additions and 0 deletions
|
@ -0,0 +1,20 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: fix_dossier_etablissement'
|
||||
task fix_dossier_etablissement: :environment do
|
||||
puts "Running deploy task 'fix_dossier_etablissement'"
|
||||
|
||||
etablissements = Etablissement.joins(:champ).where.not(dossier_id: nil).where('etablissements.created_at > ?', 1.month.ago)
|
||||
dossiers_modif = []
|
||||
etablissements.find_each do |e|
|
||||
if e.dossier
|
||||
dossier = e.dossier
|
||||
e.update!(dossier_id: nil)
|
||||
dossier.reload.etablissement = e.reload.dup
|
||||
dossier.save!
|
||||
dossiers_modif << dossier.id
|
||||
end
|
||||
end
|
||||
puts "Nb dossiers modifiés: #{dossiers_modif.size}"
|
||||
AfterParty::TaskRecord.create version: '20200528124044'
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue