No uninstall code for added custom database fields/tables

Started by Doug Heffernan, March 04, 2019, 06:29:56 AM

Previous topic - Next topic

Doug Heffernan

I am looking to write a mod that adds its own database table and so far so good. However, I did not find any example of uninstall the custom database stuff added either in the mods database or in the various mods that I checked out. i.e. the custom tables/fields added by mods will remain in the database after the mods are uninstalled. Is this as designed or overlooked? Or does such a function exists and I have missed it.

Arantor

If you use the <database> tag to call your code and you use the proper smcFunc calls, all new tables and columns are automatically logged during installation, and the user will be given the choice to remove them during uninstallation.

For a more complete example of installation and uninstallation, check out SimpleDesk, which will outline what needs cleaning up where and how (e.g. how to have forcibly run code at uninstallation versus cleanup that only runs if the user picks the full clean up option)

Doug Heffernan

Quote from: Arantor on March 04, 2019, 07:10:43 AM
If you use the <database> tag to call your code and you use the proper smcFunc calls, all new tables and columns are automatically logged during installation, and the user will be given the choice to remove them during uninstallation.

For a more complete example of installation and uninstallation, check out SimpleDesk, which will outline what needs cleaning up where and how (e.g. how to have forcibly run code at uninstallation versus cleanup that only runs if the user picks the full clean up option)

Thank you sir. I will check out SimpleDesk.

Yes, I was using the <database> tag but it did not uninstall my custom table as far as I could see. I also checked several mods in the Mods section that added to the database and same thing. SO I was wondering about it.

Kindred

Most mods do not uninstall database changes, because upgrading the mod usually involved uninstall and reinstall....

if you did use the database tags and the fully SMF database functions, then - on uninstall - there should have been a checkbox option to "completely uninstall" or something like that.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

A lot of mods do it badly, where they have a regular DB query instead of using $smcFunc['db_create_table'].

Also a lot of mods use the code tag when they really should use the database tag.

Doug Heffernan

Quote from: Kindred on March 04, 2019, 07:48:02 AM
Most mods do not uninstall database changes, because upgrading the mod usually involved uninstall and reinstall....

if you did use the database tags and the fully SMF database functions, then - on uninstall - there should have been a checkbox option to "completely uninstall" or something like that.

I did not notice the completely uninstall option. Maybe I missed it.

Advertisement: