Table of contents

Change an organisation's slug

NOTE: for Worldwide Organisations, only Steps 1 and maybe 6 below need to be performed.

The organisation slug is used as a foreign key for organisations across lots of apps. Changing it can be complex and time consuming.

1) Change the organisation’s slug in Whitehall

Create a data migration that uses the DataHygiene::OrganisationReslugger class, see this PR for an example.

2) Update the organisation in the Need API:

  • Pull the new organisation slug from Whitehall using the organisations:import rake task.
  • In the Rails console, update all needs with the new organisation:
  Need.where(organisation_ids: old_slug).each { |n| n.organisation_ids = (n.organisation_ids - [old_slug] + [new_slug]); n.save! }
  • Use Organisation.find(old_slug).destroy to delete the old organisation.
  • Re-index the needs in search via the search:index_needs rake task.

3) Clear the organisation cache in Maslow:

Restart the workers using Fabric:

fab $environment class:backend sdo:'service maslow reload'

4) Update the organisation in Transition/transition-config:

The transition-config repo may contain slugs. Change any references to the old slug:

5) Update the organisation slug in Manuals Publisher

Repo: https://github.com/alphagov/manuals-publisher

Find out if any manuals are published by this organisation.

Run the following in manuals-publisher Rails console:

ManualRecord.exists?(conditions: { organisation_slug: "old-slug" })

If there are, create a migration to update the slugs. Republish all affected manuals after deploying your change.

6) Update any best-bet searches in Search Admin

https://search-admin.publishing.service.gov.uk/

This page is owned by #2ndline and needs to be reviewed