# Linked Application pointing to cloud upstream\_app\_id after full local server migration

**URL:** <https://forum.dimagi.com/t/linked-application-pointing-to-cloud-upstream-app-id-after-full-local-server-migration/12551>\
**Category:** Developers\
**Created:** [November 13, 2026, 4:14am UTC](https://forum.dimagi.com/t/linked-application-pointing-to-cloud-upstream-app-id-after-full-local-server-migration/12551 "2026-11-13T04:14:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![demis08](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/demis08/32/1234_2.png) [@demis08](https://forum.dimagi.com/u/demis08)\
**Post date:** [November 13, 2026, 4:14am UTC](https://forum.dimagi.com/t/linked-application-pointing-to-cloud-upstream-app-id-after-full-local-server-migration/12551/1 "2026-11-13T04:14:19Z")

</div>

Hello Team,

We have recently completed a full migration of our CommCare HQ environment from the Dimagi cloud to a self-hosted local server infrastructure. We are now in the final stages of our deployment, but we have encountered a structural linking issue with our linked applications.

#### Setup & Context:

- **Production Domain Space:** `mc-inscale` (contains two linked applications: _aplicativo do APS_ and _aplicativo do supervisor_). the client wants to maintain and continue to use all the versions that are part of the downstream applications

- **Development Domain Space:** `mc-inscale-dev` (contains the active source applications: _aplicativo do APS_ and _aplicativo do supervisor_). The development space was copied down to our new local server, which generated **new application IDs** on the local instance.

- **Client Requirements:**

1. The client needs to maintain and continue to use all historical versions that are already part of the downstream applications.

2. Future updates should flow seamlessly from the newly established local development space (`mc-inscale-dev`) to the production space (`mc-inscale`).

#### The Issue:

We successfully established a project space link from `mc-inscale-dev` → `mc-inscale` by name, and the Linked Project Spaces pages correctly show them linked to each other on our local server.

However, the individual linked applications are still pointing to the legacy Dimagi cloud `upstream_app_id` from before the migration rather than the new local app IDs generated when the dev space was copied down.

When inspecting via the Django shell (`./manage.py shell`), we verified the following:

> from corehq.apps.app\_manager.dbaccessors import get\_app  
> app = get\_app("mc-inscale", "c2161fa6d8bded80ecad5edd91582e32") # (aplicativo do APS linked)  
> print(app.doc\_type, app.upstream\_app\_id, app.upstream\_version)
> 
> Output:
> 
> LinkedApplication 240a8a42523112581841db1c0f15fd9e 5918

The `upstream_app_id` (`240a8a42523112581841db1c0f15fd9e`) still maps to the old cloud ID instead of the new local application ID residing in `mc-inscale-dev`.

#### Question:

What is the recommended method or management command to safely update or remap the `upstream_app_id` of an existing `LinkedApplication` to point to the new local development app ID without breaking sync functionality or release histories?

Any guidance or python snippet to handle this mapping update cleanly in the DB would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![gherceg](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/gherceg/32/1804_2.png) [@gherceg](https://forum.dimagi.com/u/gherceg)\
**Post date:** [November 13, 2026, 2:12pm UTC](https://forum.dimagi.com/t/linked-application-pointing-to-cloud-upstream-app-id-after-full-local-server-migration/12551/2 "2026-11-13T14:12:17Z")

</div>

Hi Demis,

You could try using the `link_apps` management command for each upstream/downstream pair, which should update the downstream apps to correctly reference the new upstream apps.

```auto
./manage.py link_apps <upstream_app_id> <downstream_app_id>

```

Prior to running this, make sure of the following:

- a released build in the mc-inscale-dev project exists for each app that has been copied from the production server, as the command relies on this.
- generally good practice to create a build of each downstream project prior to running this, just to have a clean point to revert to if needed.

Let us know how it goes.

---

<div class="post-metadata">

**Author:** ![demis08](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/demis08/32/1234_2.png) [@demis08](https://forum.dimagi.com/u/demis08)\
**Post date:** [November 16, 2026, 6:37pm UTC](https://forum.dimagi.com/t/linked-application-pointing-to-cloud-upstream-app-id-after-full-local-server-migration/12551/4 "2026-11-16T18:37:17Z")

</div>

Hi Graham,

It worked! Thank you for the support. Everything is running smoothly now.
