Search code examples
joomlajoomla2.5joomla-extensions

Joomla: On extension update: Change table schema (remove column)


I have developed a Joomla extension and in the newest version the need to delete one column from a table belonging to my plugin has arisen.

As far as I know there is no easy way to delete a column in Mysql only if it exists. Therefore, the only possibility I see at the moment to achieve that, would be to use custom php upgrade code, as shown here.

But this problem would seem so common to me, that I would suspect to be an easier solution? Is there maybe an easy way (provided through Joomla) to execute a schema change only when updating from a particular extension version?


Solution

  • Check Managing Component Updates with Joomla; starting with Joomla 1.6 there is a defined way to execute specific SQL instructions for an upgrade from one version to another. Basically, for each version an SQL file has to be created (even if it's empty or only contains comments) in a specific file structure. The linked article explains the details.