Print this page

Spring'15 - Delete Components before and after Component Updates in a deployment

Knowledge Article Number 000206765

Delete Components before and after Component Updates

You can control when components are deleted in a deployment. Use a manifest to specify component deletions before updates, and use another manifest to specify component deletions after updates. Specifying the processing order of deletions relative to component updates provides you with greater flexibility and enables you to delete components with dependencies.

To delete components, use the same procedure as with deploying components, but also include the appropriate delete manifest files. The format of the delete manifest is the same as package.xml except that wildcards aren’t supported.

  • To delete components before adding or updating other components, create a manifest file that’s nameddestructiveChangesPre.xml and include the components to delete.
  • To delete components after adding or updating other components, create a manifest file that’s nameddestructiveChangesPost.xml and include the components to delete.

This feature applies to the Metadata API deploy() call or Metadata API-based tools, such as the Migration Tool.

The ability to specify when deletions are processed is useful when you’re deleting components with dependencies. For example, if a custom object is referenced in an Apex class, you can’t delete it unless you modify the Apex class first to remove the dependency on the custom object. In this example, you can perform a single deployment that updates the Apex class to clear the dependency and then deletes the custom object by using destructiveChangesPost.xml. The following are samples of thepackage.xml and destructiveChangesPost.xml manifests that would be used in this example.

Sample package.xml, which specifies the class to update:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="">

Sample destructiveChangesPost.xml, which specifies the custom object to delete after the class update:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="">


  • The API version that the deployment uses is the API version that’s specified in package.xml.
  • The destructiveChangesPre.xml and destructiveChangesPost.xml manifests are supported starting with API version 33.0. In earlier versions, only destructiveChanges.xml is supported. In API version 33.0 and later, if the processing order for deletions and additions doesn’t matter, you can continue usingdestructiveChanges.xml.
  • When you’re using destructiveChanges.xml, deletions are processed first by default.
Resolution Reference :

promote demote