Search code examples
moduleopencartocmod

Opencart ocmod rollback database changes


Using OCMOD system, in the file: install.sql i can make changes to opencart database.

The question is: if i uninstall the module, will the changes in database rollback?

If don't, how can it be done using OCMOD system? Is there an uninstall file where you can write the uninstall queries?


Solution

  • If the mod author gave you an install.sql, then just doing an uninstall will not roll back the database changes. You'll need to "reverse" whatever changes were made by the install.sql. If there's an add table, do a drop table. If there's an add field, do a drop field. etc.

    If you post the install.sql we can help you build the uninstall.sql from it.

    NOTE: A properly structured mod will have install() and uninstall() methods in its model, and will do the database modifications there; providing an install.sql file means the author didn't really know what he was doing.