diff --git a/app/tasks/maintenance/prefill_individual_email_verified_at_task.rb b/app/tasks/maintenance/prefill_individual_email_verified_at_task.rb new file mode 100644 index 000000000..fa6e045d2 --- /dev/null +++ b/app/tasks/maintenance/prefill_individual_email_verified_at_task.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +# We are going to confirm the various email addresses of the users in the system. +# Individual model (mandant) needs their email_verified_at attribute to be set in order to receive emails. +# This task sets the email_verified_at attribute to the current time for all the individual to be backward compatible +# See https://github.com/demarches-simplifiees/demarches-simplifiees.fr/issues/10450 +module Maintenance + class PrefillIndividualEmailVerifiedAtTask < MaintenanceTasks::Task + def collection + Individual.in_batches + end + + def process(batch_of_individuals) + batch_of_individuals.update_all(email_verified_at: Time.zone.now) + end + end +end diff --git a/app/tasks/maintenance/prefill_user_email_verified_at_task.rb b/app/tasks/maintenance/prefill_user_email_verified_at_task.rb new file mode 100644 index 000000000..ad3ba6f5b --- /dev/null +++ b/app/tasks/maintenance/prefill_user_email_verified_at_task.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +# We are going to confirm the various email addresses of the users in the system. +# User model needs their email_verified_at attribute to be set in order to receive emails. +# This task sets the email_verified_at attribute to the current time for all users to be backward compatible +# See https://github.com/demarches-simplifiees/demarches-simplifiees.fr/issues/10450 +module Maintenance + class PrefillUserEmailVerifiedAtTask < MaintenanceTasks::Task + def collection + User.in_batches + end + + def process(batch_of_users) + batch_of_users.update_all(email_verified_at: Time.zone.now) + end + end +end