Question

I am coding an extension for eZPublish which has an own eZPersistantObject, so it needs an own database table.

Is there any way to provide a kind of setup.php or something, which runs on extension activation and creates the table?

Thanks for your responses.

Was it helpful?

Solution

Seems like when installing extensions in your CMS you are also required to do further steps manually like doing changes to the database. See http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Installation/Extensions So I don't think that eZPublish supports this kind of setup.

You can of course do such thing manually, like do a CREATE TABLE IF NOT EXISTS on each request. A dirty solution: put your setup.php somewhere in your extension folder, make it writeable and after the first execution simply remove it. Just add unlink(__FILE__); at the end of setup.php.

If you want some cleaner solution you can have a directory with database migration scripts and a table that keeps track which of those scripts have been executed. On each request you then check if there are new migration scripts and execute, if necessary.

OTHER TIPS

eZ Publish does not provide such a feature when it comes to install an extension (and that's not true to say that you need to change things in the database to doing so, only the autoload regeneration is required).

Concerning your issue, the only thing you can do is to add a .dba file in your extension so that it's checked when using the System check / upgrade in your admin interface. The file can be generated using the ezsqldumpschema.php script in bin/php (you'll notice that a few things are missing, such as the charset, ...)

If your extension provides an admin interface, feel free to add a kind of pre_check function at the beginning of each view's script. This should check table existence against the dba file and create it if needed (or prompt the user to).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top