Skip to content

Change unique indexes for form documents to allow for multiple versions - #3021

Merged
stephencdaly merged 3 commits into
mainfrom
change-unique-indexes-for-form-documents
Aug 14, 2026
Merged

Change unique indexes for form documents to allow for multiple versions#3021
stephencdaly merged 3 commits into
mainfrom
change-unique-indexes-for-form-documents

Conversation

@stephencdaly

Copy link
Copy Markdown
Contributor

What problem does this pull request solve?

Trello card: https://trello.com/c/dGv0TrD1

Update the unique indexes for form documents so that:

  • There can only be form document with a given version per language per form
  • There can only be one form document with a null version per language per form, which accounts for draft form documents

A migration has already been run on all environments to set the version for live and archived form documents to 1

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 change-unique-indexes-for-form-documents branch 2 times, most recently from ff263af to 9ae8d85 Compare August 13, 2026 13:29
@stephencdaly
stephencdaly marked this pull request as ready for review August 13, 2026 13:39
@stephencdaly stephencdaly changed the title Change unique indexes for form documents Change unique indexes for form documents to allow for multiple versions Aug 13, 2026
@stephencdaly
stephencdaly marked this pull request as draft August 13, 2026 13:50
@stephencdaly
stephencdaly force-pushed the change-unique-indexes-for-form-documents branch 2 times, most recently from b4ada4b to b43a8a7 Compare August 13, 2026 15:03
@stephencdaly
stephencdaly marked this pull request as ready for review August 13, 2026 15:07
lfdebrux
lfdebrux previously approved these changes Aug 14, 2026
Allow:
- One form_document with the same language and version per form
- One form_document with the same language and a null version per form
to account for draft forms

The indexes are not added concurrently, as the benefits of adding them
in a transaction outweigh the potental downsides of locking the table
for a short time.
Delete the tests for the data migration rake task to backfill versons
as the new indexes do not allow for multiple form_documents with the
same language and a null version per form. This rake task has been run
in all environments - but we'll keep it around slightly longer so devs
can run it if they need to backfill their local databases.
@stephencdaly
stephencdaly force-pushed the change-unique-indexes-for-form-documents branch from b43a8a7 to 36f6228 Compare August 14, 2026 09:15
@stephencdaly

Copy link
Copy Markdown
Contributor Author

@theseanything I've updated to not add the indexes concurrently and instead use a transaction, as discussed

@github-actions

Copy link
Copy Markdown

🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-3021.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 Aug 14, 2026
Merged via the queue into main with commit fc782db Aug 14, 2026
3 checks passed
@stephencdaly
stephencdaly deleted the change-unique-indexes-for-form-documents branch August 14, 2026 10:27
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