Skip to content

Create AccessLimitingOrganisations from Editions [WHIT-3534]#11548

Open
davidsauntson wants to merge 1 commit into
mainfrom
migrate-access-limiting-orgs
Open

Create AccessLimitingOrganisations from Editions [WHIT-3534]#11548
davidsauntson wants to merge 1 commit into
mainfrom
migrate-access-limiting-orgs

Conversation

@davidsauntson

Copy link
Copy Markdown
Contributor

What

This change introduces a data migration that creates a new AccessLimitingOrganisation entry for each edition lead and supporting organisation and saves it to the db.

Why

As part of the work to limit edition access to named individuals, the modelling for access limiting by organisation is changing. Now that the new AccessLimitingOrganisation model exists, we need to populate the db table with data from Editions who have access_limiting set to organisations, so that the new limiting logic has data to work with.


⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

This application is owned by the Whitehall Experience team. Please let us know in #govuk-whitehall-experience-tech when you raise any PRs.

Follow these steps if you are doing a Rails upgrade.

@davidsauntson davidsauntson changed the title Create AccessLimitingOrganisations from Editions Create AccessLimitingOrganisations from Editions [WHIT-3534] Jun 10, 2026

@ChrisBAshton ChrisBAshton 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.

LGTM - one tweak below.

I'd hold off on merging until we're ready to switch on the feature flag to enable the UI view, as per the Release plan.

errors << "Edition #{edition.id} cannot save new `AccessLimitingOrganisation` #{limiting_org.name}`: #{access_limiting_org.errors.full_messages.to_sentence}"
end

edition.access_limiting_organisations = access_limiting_orgs

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.

I'd move this outside of the block so we're not calling access_limiting_organisations= multiple times per edition

As part of the work to limit edition access to name individuals, the modelling for access limiting by organisation is changing.  Now that the new `AccessLimitingOrganisation` model exists, we need to populate the db table with data from `Editions` who have `access_limiting` set to `organisations`, so that the new limiting logic has data to work with.

This change introduces a data migration that creates a new `AccessLimitingOrganisation` entry for each edition lead and supporting organisation and saves it to the db.
@davidsauntson davidsauntson force-pushed the migrate-access-limiting-orgs branch from 665b3ca to 1c0a416 Compare June 10, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants