# Adding Pre and Post Destructive Changes to a Branch

## ![](/files/RXx59Hu9EyPCisSQ0YzA) 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 will show you how to add a pre-destructive change.

## Adding Destructive Changes

{% stepper %}
{% step %}

### Select a Branch

1. Click **Code** from the left sidebar menu.
2. Select a branch from the list.&#x20;

   <div align="left"><figure><img src="/files/yum0KnaMvFtXlmPr8k28" alt="" width="563"><figcaption></figcaption></figure></div>

{% endstep %}

{% step %}

### Add Desctructive Changes

1. Scroll down to the **Destructive changes** section.
2. Click **Add per destructive changes**.&#x20;

   <div align="left"><figure><img src="/files/LIzt5sIdqSazYY1NdMh9" alt="" width="563"><figcaption></figcaption></figure></div>
3. Select the **Source Type**:&#x20;

   1. **Connection**: Lets you choose components from a Salesforce org connection to include in destructive changes.
   2. **Branch**: Lets you choose components from a branch to include in destructive changes.

   <div align="left"><figure><img src="/files/LbwZ1EQ7cjLybCRCqGha" alt="" width="563"><figcaption></figcaption></figure></div>
4. Click **Select** for the Connection or Branch from which you want to add components.
5. Click **Next**.&#x20;

   <div align="left"><figure><img src="/files/bAUMOvj4Ilxwvh41sfEH" 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.&#x20;

   <div align="left"><figure><img src="/files/k6Qlnyk7us2JgCYINMlI" alt="" width="563"><figcaption></figcaption></figure></div>
2. Click **Add** for each component to add.
3. Click **Next** once all components are added.&#x20;

   <div align="left"><figure><img src="/files/469WJEN07fnAzGh2Kw2z" alt="" width="563"><figcaption></figcaption></figure></div>
4. The components you added will be listed in the **Destructive changes** table. The type of destruction is listed to the right of the component name.&#x20;

   <div align="left"><figure><img src="/files/sCURcnXhFkrYnW3M4bpg" 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 editing its deployment type or removing it.

{% stepper %}
{% step %}

### Edit Destructive Change

{% hint style="info" %}
When editing a destructive change, the only option is to alter the deployment type.
{% endhint %}

1. Click the **Three Dots** menu for the destructive change you want to edit.
2. Click **Edit**.&#x20;

   <div align="left"><figure><img src="/files/Ho1kQD2Z6GevDyKdZkmj" alt="" width="563"><figcaption></figcaption></figure></div>
3. Select the **Deploy Type**.
4. Click **Save**.&#x20;

   <div align="left"><figure><img src="/files/I80US9wbVfQDeUcQ4onB" alt="" width="375"><figcaption></figcaption></figure></div>

{% endstep %}

{% step %}

### Delete Destructive Change

1. Click the **Three Dots** menu for the destructive change you want to edit.
2. Click **Delete**.&#x20;

   <div align="left"><figure><img src="/files/QJsULgkXyA7rOiDAGu4P" alt="" width="563"><figcaption></figcaption></figure></div>
3. Click **Yes**.&#x20;

   <div align="left"><figure><img src="/files/DhXZyomPzik4lZMtbj96" alt="" width="375"><figcaption></figcaption></figure></div>

{% endstep %}
{% endstepper %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
