<p>The trick is to do it in two separate steps…</p>
<ol>
<li><strong>Uninstall the plugin via Craft.</strong> Push those changes all the way through to your production environment.</li>
<li><strong>Uninstall the plugin via Composer.</strong> Push those changes all the way through to your production environment.</li>
</ol>
<p>By doing this as two distinct steps, it gives your production (and staging) environment a chance to properly run the plugin’s uninstall migrations <em>while the composer package is still available</em>. Once you remove the composer package (Step 2), the plugin won’t really know <em>how</em> to uninstall itself.</p>

CC BY-SA 4.0
2024-02-17T14:48:50.350Z
2024-02-17T14:48:50.350Z
Lindsey D
<p>I have read the following article <strong>best practices for deployments</strong>.</p>
<p><a href="https://craftcms.com/knowledge-base/deployment-best-practices" rel="nofollow noreferrer">https://craftcms.com/knowledge-base/deployment-best-practices</a></p>
<p>here the following is recommended:</p>
<pre><code>git pull
composer install
php craft up
</code></pre>
<p>The problem here is if I have uninstalled a plugin that has tables they are not removed with the &quot;php craft up&quot; command.</p>
<p>I also tried the following instead of <code>composer install</code> -&gt; <code>php craft update/composer-install</code> because I thought that this would be taken into account here but unfortunately it is not taken into account here either.</p>
<p>Is there a way to remove the tables automatically if this plugin has been removed or do I have to uninstall the plugins manually?</p>

<craft3><craft-features><deployment><git><commands>
Deployment strategy that removes tables from uninstalled plugins
# Deployment strategy that removes tables from uninstalled plugins

(Asked by: username_0 on 2024-02-17)

I have read the following article best practices for deployments.
https://craftcms.com/knowledge-base/deployment-best-practices
here the following is recommended:
git pull
composer install
php craft up

The problem here is if I have uninstalled a plugin that has tables they are not removed with the "php craft up" command.
I also tried the following instead of composer install -> php craft update/composer-install because I thought that this would be taken into account here but unfortunately it is not taken into account here either.
Is there a way to remove the tables automatically if this plugin has been removed or do I have to uninstall the plugins manually?

**Tags:** craft3, craft-features, deployment, git, commands

---

## 1 answers

### Answer by username_1 on 2024-02-17. Score: 3 | Accepted answer

The trick is to do it in two separate steps…

1. **Uninstall the plugin via Craft.** Push those changes all the way through to your production environment.
2. **Uninstall the plugin via Composer.** Push those changes all the way through to your production environment.

By doing this as two distinct steps, it gives your production (and staging) environment a chance to properly run the plugin’s uninstall migrations *while the composer package is still available*. Once you remove the composer package (Step 2), the plugin won’t really know *how* to uninstall itself.


---

