fix(migration): backfill procedure nil duree_conservation_etendue_par_ds

This commit is contained in:
François Vantomme 2023-01-03 14:29:44 +01:00 committed by LeSim
parent ecd24378d6
commit f0ff364ed6

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