Background: a managed package's namespace prefixes every API name (acme__Object__c). Once a package is in production, changing the namespace is essentially impossible without rebuilding it as a new package and migrating data — Salesforce does not support direct namespace migration.
So when this comes up, it's typically because:
- The package was built unmanaged or with a temp namespace and now needs to go ISV-managed.
- A namespace was deprecated or transferred between Dev Hubs.
- Multi-org consolidation requires unifying packages.
The "migration" is really a parallel rebuild + data migration:
- Build the new package in a fresh Dev Hub with the target namespace. Replicate all metadata. This is mostly automated via Salesforce DX (
sf project retrievefrom old,sf project deployto new). - Install the new package in target orgs alongside the old one. Both run in parallel during transition.
- Migrate data. Custom object data must be copied row-by-row from
oldns__Object__ctonewns__Object__c. Use Data Loader with field mapping, or a script via Apex Batch / external ETL. - Migrate references. All Lookup fields, formula fields, and Apex code referencing
oldns__need to be updated tonewns__. This is where most of the work is. - Test in sandbox extensively. Side-by-side comparison of old vs new during a quiet period.
- Cut over — disable old package's UI/automations, enable new, validate, then uninstall old (which deletes the old data — back it up first).
Risks:
- Lookup field re-pointing — every record's lookup needs the new id. Doing this at scale without breaking sharing or breaking referential integrity requires careful sequencing.
- History gap — Field History on the old object doesn't migrate. You either accept the gap or export-and-store-elsewhere.
- Integrations — every external system referencing
oldns__Object__cneeds to be updated tonewns__Object__c. This is the largest blast radius. - Reports and dashboards — referencing the old API names break. Rebuild against the new package's report types.
- Custom code referencing
oldns__— must be rewritten and redeployed. - Validation rules and flows — same.
The honest answer: namespace migration is one of the biggest projects an admin/architect can take on. The decision is usually "do not start" unless absolutely necessary. The right answer in an interview is to surface those risks first, then describe the rebuild strategy.
