nopCommerce icon indicating copy to clipboard operation
nopCommerce copied to clipboard

Add a way to keep plugin data when uninstalling

Open RomanovM opened this issue 1 year ago • 2 comments

nopCommerce version: 4.60

We need a generic way to keep plugin data when uninstalling to avoid creating such a method in each plugin.

Suggestion: https://www.nopcommerce.com/boards/topic/84184/remove-all-plugin-tables-on-plugin-uninstall-setting

RomanovM avatar Feb 19 '24 07:02 RomanovM

I have two settings in my Plugins

Delete Plugin Tables on Uninstall - If ticked it will delete the tables

  • Does mean you need to implement Up and Down methods and check the setting before deleting tables
  • Need to check if tables exisit before creating on install (which I think is standard now)

Delete Configuration Data on Uninstall - If ticked will delete the settings assicated withthe plugin

  • Need to check if the settings exist before overwriting on install

If ever needed you have to option of completely unistall and delete plugin but not loose config and/or tables

Note: this comment pertains to the Setting table specifically, not files stored on the file system. Our use case is primarily lost Settings row data in the database.

One way to implement this might be to keep the previous settings in another table, or column within the existing table. PreviousSettingValue column, or perhaps setting history linking table with versions and dates. I don't think for most cases the history has to be comprehensive and n - 1 would be adequate.

To me, the overall goal would be if a plugin is uninstalled and then subsequently re-installed it either just takes the last settings or prompts the user to take the last settings. Or maybe add a checkbox to optionally import the previous settings when installing the plugin.

hoffmanntravis avatar Jun 03 '24 18:06 hoffmanntravis