OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.22k stars 2.34k forks source link

Functionality missing for uninstalling Modules #2562

Open scleaver opened 5 years ago

scleaver commented 5 years ago

There is currently no way both programmatically and via the UI to uninstall a module. When you create a ContentType or add Content Parts via a module, disabling the module does not remove them from the UI.

Here is the scenario: I have a bunch of tenants that are hosted on Orchard Core. I have created a Module called Locations which adds an AddressPart (for containing addresses) and a ContentType called Locations (added by migrations.cs) and associated methods for querying and displaying Locations.

The tenant decides the no longer wants the Locations functionality as part of their subscription. Disabling it via the Module UI does not remove the AddressPart and the ContentType from the tenant. What I am after is a method that could be utilized to perform cleanup when a module is no longer needed.

Skrypt commented 5 years ago

After discussion with @scleaver and looking in the code I saw that we have a InstallState for all modules but it's always set to "Up" and never really used anywhere in the code. I think it's there because previously in 01 we could uninstall modules because of dynamic compilation. It's not the case anymore, so we could use the already implemented feature "Uninstall" and adapt it so that we could have a Uninstall button displayed on each modules that implements an Uninstall method in their Migrations.cs file.