Skip to content

Add DeliveryConfigurations for forms to allow sending submissions by multiple methods#2933

Merged
stephencdaly merged 10 commits into
mainfrom
add-delivery-configurations-table
Jul 16, 2026
Merged

Add DeliveryConfigurations for forms to allow sending submissions by multiple methods#2933
stephencdaly merged 10 commits into
mainfrom
add-delivery-configurations-table

Conversation

@stephencdaly

@stephencdaly stephencdaly commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

What problem does this pull request solve?

Trello card: https://trello.com/c/WMnjLlJV/245-allow-both-email-and-s3-submissions-simultaneously

Move the settings that decide where we send a form's submissions to a delivery_configurations table, which has a many to one relationship with forms.

This will allow for submissions to be sent by both email and to an s3 bucket for the same form.

Also add DeliveryConfiguration records for batch submissions, which are identified by the frequency column.

This PR ensures that appropriate DeliveryConfigurations are created when a form is updated, and adds a data migration rake task to create records for existing forms.

We do not yet consume the DeliveryConfigurations, for example to determine the content to display on the live form page but will do in a subsequent PR once the data migration has been run.

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Do the end to end tests need updating before these changes will pass?
  • Has all relevant documentation been updated?

@stephencdaly
stephencdaly force-pushed the add-delivery-configurations-table branch from a7be648 to d55c133 Compare July 15, 2026 09:58
@stephencdaly stephencdaly changed the title Add delivery configurations table Add DeliveryConfigurations for forms to allow sending submissions by multiple methods Jul 15, 2026
@stephencdaly
stephencdaly force-pushed the add-delivery-configurations-table branch from d55c133 to 62c250d Compare July 15, 2026 11:14
@stephencdaly
stephencdaly marked this pull request as ready for review July 15, 2026 11:22

@thomasiles thomasiles left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for me, nice one 🏅

thomasiles
thomasiles previously approved these changes Jul 15, 2026
Comment thread app/models/form.rb Outdated
Comment thread db/migrate/20260715095436_create_delivery_configurations.rb Outdated
Comment thread app/models/form.rb Outdated
Comment thread lib/tasks/forms.rake
Comment thread app/input_objects/forms/batch_submissions_input.rb
Comment thread app/input_objects/forms/submission_email_input.rb Outdated
@stephencdaly

Copy link
Copy Markdown
Contributor Author

@theseanything thanks for the review, I'll make all those changes.

We're adding this table so that we can configure a form to deliver to
multiple destinations.

The `delivery_method` will be "email" or "s3", and replaces the
`submission_type` column on the `forms` table.

The `formats` column replaces the `submission_format` column on the
`forms` table.

The `delivery_schedule`` can be either "immediate", "daily", or
"weekly". This matches the delivery_schedules we store in the
forms-runner database on the `delivery` table. We will replace the
`send_daily_submission_batch` and `send_weekly_submission_batch`
columns on the `forms` table by adding extra `delivery_configuration`
records for the form with appropriate delivery_schedules.

This data model could be further iterated in future to move the
`submission_email`, `s3_bucket_name` and other s3 settings to the
`delivery_configurations` table. This might lead to some duplication
of the configuration settings between different delivery
configurations for the same form - i.e. for immediate and daily email
deliveries. However, there is a need from users to sometimes send
submissions to different or multiple email addresses.
When the submission email is confirmed for a form, create a
DeliveryConfiguration with delivery_method set to 'email' and
frequency set to 'immediate', if a matching DeliveryConfiguration does
not already exist for the form.

The presence or not of a DeliveryConfiguration will be used instead
of the `submission_type` on the Form to determine whether to send
individual submissions by email.
When daily/weekly batch submission emails are are enabled or disabled,
create or destroy the appropriate DeliveryConfiguration records for
the form.

DeliveryConfigurations will replace the `send_daily_submission_batch`
and `send_weekly_submission_batch` form attributes.
When csv/json attachments are enabled or disabled for email
submissions,
update the immediate email DeliveryConfiguration with the new formats.
Update the rake tasks that change the submission type between email
and S3 to also add/remove the corresponding DeliveryConfiguration
records.

We'll need to update these tasks further when we add the ability for
both email and S3 immediate delivery to be enabled at the same time,
but for now just update them to ensure we keep the
DeliveryConfiguration records in sync with the submission type.
The rake task updates all existing forms to have a
DeliveryConfiguration with settings from the form's submission_type
and submission_format, and additional DeliveryConfigurations if the
form has daily or weekly batches enabled.

Updates the form documents with delivery_configurations corresponding
to the settings on the existing form_document, which might be
different to the settings on the form for live and archived form
documents.
Delete the existing DeliveryConfigurations for the form and recreate
them from the live form document when reverting a draft form.
We already do not copy the submission email when copying a form to
require users to make an active decision about where submissions go.

To be consistent, also do not copy the s3 bucket configuration when
copying a form.

We will also not copy the DeliveryConfigurations for a form, so users
will need to decide if they want submission emails to include CSV or
JSON attachments, and whether they want to receive daily or weekly
submission emails.
@stephencdaly
stephencdaly force-pushed the add-delivery-configurations-table branch from 0e6a6f8 to e492bc6 Compare July 16, 2026 12:08
@github-actions

Copy link
Copy Markdown

🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-2933.admin.review.forms.service.gov.uk/

It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready
after 5 minutes, there may be something wrong with the ECS task. You will need to go to the integration AWS account
to debug, or otherwise ask an infrastructure person.

For the sign in details and more information, see the review apps wiki page.

@stephencdaly
stephencdaly added this pull request to the merge queue Jul 16, 2026
Merged via the queue into main with commit 441c509 Jul 16, 2026
3 checks passed
@stephencdaly
stephencdaly deleted the add-delivery-configurations-table branch July 16, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants