> For the complete documentation index, see [llms.txt](https://docs.flosum.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flosum.com/devops/code/branch-actions/adding-pre-and-post-destructive-changes-to-a-branch.md).

# Adding Pre and Post Destructive Changes to a Branch

Use destructive changes to remove Salesforce metadata components during deployment. You can configure them as Pre or Post to control when the deletions happen.

## ![](https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FG5ZbxX918xOHwbAwAJ4n%2FSummary2-Small-Icon.svg?alt=media\&token=da26a67f-ff7f-47b3-8669-06be960dc2d7) Overview <a href="#what-are-destructive-changes" id="what-are-destructive-changes"></a>

Destructive changes allow you to delete metadata from a Salesforce org as part of a deployment. For example, you may want to remove unused fields, classes, or components. In Flosum DevOps, destructive changes can be applied in two ways:

* **Pre-destructive changes**: deletions occur before the main deployment.
* **Post-destructive changes**: deletions occur after the main deployment.

{% hint style="warning" %}

#### Deployment

When you run a **Deploy** or **Validate** action, destructive changes are included automatically. They execute in sequence, depending on whether they are Pre or Post.
{% endhint %}

{% hint style="info" %}

#### Best Practices

* Use **pre-destructive** changes to remove metadata that might conflict with the new deployment.
* Use **post-destructive** changes to clean up after the new components are deployed.
* Always validate deployments with destructive changes to ensure no critical metadata is deleted by mistake.
  {% endhint %}

Since the steps for adding a pre-destructive change and a post-destructive change are the same, this article shows you how to add a pre-destructive change.

## Adding Destructive Changes

{% stepper %}
{% step %}

### Select a Branch

1. Click **Branches** from the left sidebar menu.
2. Select a branch from the list.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2Fa9KT0NxgbPAX6fQdWcPM%2FAddingPreAndPostDestructiveChangesToABranch-S01-01.png?alt=media&amp;token=a362e977-c0df-4838-9cd3-cd58e3001cb2" alt="" width="563"><figcaption></figcaption></figure></div>

{% endstep %}

{% step %}

### Add Destructive Changes

1. On the **Components** tab, click the **Destructive Changes** table selector.
2. Click **+ Add Pre Change**.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FZ4tnq4khwzR5DyQQm1PN%2FAddingPreAndPostDestructiveChangesToABranch-S02-02.png?alt=media&amp;token=c9ebe56b-76e6-4837-96e1-509be8297707" alt="" width="563"><figcaption></figcaption></figure></div>
3. Select the **Source Type**:
   1. **Organization**: Lets you choose components from a Salesforce org to include in destructive changes.
   2. **Branch**: Lets you choose components from a branch to include in destructive changes.
4. Click **Continue**.&#x20;

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FEi1HHERVF1mTubJ9rRWe%2FAddingPreAndPostDestructiveChangesToABranch-S02-04.png?alt=media&amp;token=13abdce9-ea69-4fd7-9b15-2557fa9a0433" alt="" width="375"><figcaption></figcaption></figure></div>
5. Click **Select** for the Organization or Branch from which you want to add components.
6. Click **Next**.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FI9cALtMPR9ehPu8aETC0%2FAddingPreAndPostDestructiveChangesToABranch-S02-05.png?alt=media&amp;token=0df51aab-2462-4a6c-96bc-caf68ad4c65c" alt="" width="563"><figcaption></figcaption></figure></div>

{% endstep %}

{% step %}

### Select Components

1. Search, filter, and sort to find the components to add to the destructive changes.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FVWx6mWcS9lHvxGSQI1Bo%2FAddingPreAndPostDestructiveChangesToABranch-S03-01.png?alt=media&amp;token=ba0a322d-3659-4199-9419-6b6f1c536ee7" alt="" width="563"><figcaption></figcaption></figure></div>
2. Click **Select** for each component to add.
3. Click **+ Add** once all components are selected.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2F3aKgNXt32MppKptRLnFn%2FAddingPreAndPostDestructiveChangesToABranch-S03-02.png?alt=media&amp;token=d2d48820-1b33-4d5b-8aed-3af8c09d4c21" alt="" width="563"><figcaption></figcaption></figure></div>
4. The components you added are listed in the **Destructive Changes** table. The **Deploy Type** column shows whether each change is **Pre** or **Post**.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FVLKP1RRnGfCBEHc0T3DS%2FAddingPreAndPostDestructiveChangesToABranch-S03-03.png?alt=media&amp;token=9f85cf48-2aaf-4644-a290-d019bc200f41" alt="" width="563"><figcaption></figcaption></figure></div>

{% endstep %}
{% endstepper %}

## Managing Destructive Changes <a href="#managing-destructive-changes" id="managing-destructive-changes"></a>

After adding a component to the **Destructive Changes** table, you can manage it by changing its deployment type or removing it completely.

{% stepper %}
{% step %}

### Change Deployment Type

You can switch the deployment type between **Pre** and **Post**. The **Change to Post/Pre** option depends on the Deploy Type the destructive change is currently set to.

1. Click the **Three Dots** menu for the destructive change you want to update.
2. Click **Change to Post/Pre**.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FLPBy5LA6ZTYwzrskZEUW%2FAddingPreAndPostDestructiveChangesToABranch-S04-01.png?alt=media&amp;token=fdfc983b-9c32-4756-837e-c17ea7b71d27" alt="" width="563"><figcaption></figcaption></figure></div>
3. The destructive change will immediately switch Deploy Types.
   {% endstep %}

{% step %}

### Delete Destructive Change

1. Click the **Three Dots** menu for the destructive change you want to delete.
2. Click **Delete**.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FG43GszvoyjkF4gBhXGZe%2FAddingPreAndPostDestructiveChangesToABranch-S04-02.png?alt=media&amp;token=7656fdc4-e538-466a-9584-5ec6f898728d" alt="" width="563"><figcaption></figcaption></figure></div>
3. Click **Yes, delete** in the **Delete Component** confirmation dialog.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FlcNtMKdKrUhsGcRM5rSk%2FAddingPreAndPostDestructiveChangesToABranch-S04-03.png?alt=media&amp;token=18f82b87-4b32-4181-b674-e8b48f1799a7" alt="" width="375"><figcaption></figcaption></figure></div>

{% hint style="info" %}
Deleting the destructive change component does not delete the component from the branch; it only removes it from the destructive changes.
{% endhint %}
{% endstep %}
{% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flosum.com/devops/code/branch-actions/adding-pre-and-post-destructive-changes-to-a-branch.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
