# How to move or rename a tenant from one folder to another

This guide describes how to migrate all of a tenant's files to a different folder while avoiding duplicates in production.

We sometimes need to change the folder of a tenant, inside the same Media Group repository. The most common cause is if the website has an apex domain (ie. doesn't use www.), but the folder exists with www., and vice-versa. It is also possible that the folder uses a subdomain when it shouldn't, or vice-versa.

If you follow this guide to move the tenant from one code repository to another, you additionally have to delete the original tenant folder.

IMPACT

Take into account that a change from apex to www. can have a really big impact when it comes to push notifications. Make sure that CS and the client are aware of this before proceeding with the changes.

More info in the impacts article.

# Step 1: Create the new folder

  1. Create the new folder, and fill it with all the existing files.
  2. Update all the path/URLs everywhere: in publisher.json, widgets.json definition.json, ...

Check each JSON docs before making a change

The hostname in twister.json is always with the APEX format.

Verify that the URL change is necessary before doing a blanket search-and-replace.

  1. Make sure it compiles in local, extraction and statics. If changing Media Group:

    1. Find if the tenant is using any imports or extends.
    2. Copy the needed files from the old Media Group
  2. In order to avoid conflicts with invalidation jobs, if the tenant is using scheduled invalidation jobs (quartzInvalidation is true or not present), temporarily set the quartzInvalidation flag to false in both the new and old definition.json files. This will delete the automatic invalidation jobs. This will delete the automatic invalidation jobs.

Health center

Check if the jobs already exist:

  1. Create a pull request with the changes, and gather reviews from all the relevant code owners.
  2. Force a manual invalidation after deploying, to update all the production content. Go back to the health center page and check that the invalidation jobs have been deleted (ie: glue invalidate --production).

# Step 2: Insight migration

If you are not changing Media Group you can skip this step.

If you need to change the mediagroup, send a slack message with the JIRA ticket to ask-alot slack channel. Team Alot will handle the Insight migration and notify you once it's complete.

WARNING

Do not delete the old files until 48h after the change in Insight is done to prevent cache issues.

Verify that the sellerId value in twister.json has been set accordingly.

# Step 3: Delete the old folder

Once the new folder is deployed and working as expected, delete the old one to avoid any confusion.

  1. Make sure other tenants in the Media Group are not using files from the folder to be deleted.
  2. Delete all the files except the publisher.json from the old folder.
  3. Create a pull request and deploy.
  4. Go to the Media group "Deploy" repository, to make sure your changes are applied.
  5. You can now delete the old folder completely!

# Step 4: Activate the invalidation jobs for the new folder

  1. If quartzInvalidation flag was added/modified in step 1.4 set its initial value on the new definition.json file. E.g. If the flag was set to true, at this point it should be true on the new definition.json.

  2. Force an invalidation and check in the health center that the invalidation jobs have been correctly created.

TIP

If the jobs are not created, a PUT to Marfeel database is required. Escalate the issue with your tech lead, who should have the right credentials.

# Step 5: Change the domain on OneSignal

Follow the dedicated guide.