Merge pull request #8402 from adullact/fix/backfill-procedure-with-discarded

Backfill procedure with discarded
This commit is contained in:
LeSim 2023-01-11 11:07:48 +01:00 committed by GitHub
commit c44614e7cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,10 +1,16 @@
class ReBackfillProcedureMaxDureeConservationDossiers < ActiveRecord::Migration[6.1]
def change
Procedure.where(duree_conservation_etendue_par_ds: true).in_batches do |batch|
Procedure.with_discarded.where(duree_conservation_etendue_par_ds: true).in_batches do |batch|
batch.update_all(max_duree_conservation_dossiers_dans_ds: Procedure::OLD_MAX_DUREE_CONSERVATION)
end
Procedure.where(duree_conservation_etendue_par_ds: false).in_batches do |batch|
Procedure.with_discarded.where(duree_conservation_etendue_par_ds: false).in_batches do |batch|
batch.update_all(max_duree_conservation_dossiers_dans_ds: Procedure::NEW_MAX_DUREE_CONSERVATION)
end
Procedure.with_discarded.where(duree_conservation_etendue_par_ds: nil).in_batches do |batch|
batch.update_all(
duree_conservation_etendue_par_ds: false,
max_duree_conservation_dossiers_dans_ds: Procedure::NEW_MAX_DUREE_CONSERVATION
)
end
end
end