How should plugins create database tables / columns

Some of the Zenphoto plugins I have created require additional database tables to be added to the existing Zenphoto DB, or add additional columns to existing tables.

I'm fine with the SQL code itself to create the tables / columns, as well as the checks that ensure they are not created if they already exist.

My problem - is there an 'install' callback so that a Zenphoto plugin can only complete the above tasks on installation, instead of on every page load?

Comments

  • acrylian Administrator

    Generally you should try to use the general plugin_storage table if you need extra data stores.

    If that is not enough, best create custom tables. Adding fields to existing tables may cause trouble because core Zenphoto does not know about them.

    Generally the constructor of the plugin's options class is used to create defaults. Otherwise you need to store some option or check if all is already in place.

  • acrylian Administrator

    If the option class constructor is not fitting your purpose, you can also consinder to create a utility button/url so people have to run a setup routine to create necessary extra tables.

Sign In or Register to comment.