[RCD] plugin install with SQL and database prefix

Sébastien BLAISOT sebastien at blaisot.org
Sun Jan 5 01:41:58 CET 2020

Hi dear roundcube community,

First of all, I wish you all a happy new year.

I am the maintainer of the automatic_addressbook plugin (or at least I 
used to be, as I don't have much time for it now, and I would be happy 
to have it integrated in roundcube default plugins if you want, but 
that's an other story) .

I regularly get issues from users regarding database prefix when 
installing the plugin. I understand this is complicated to handle when 
installing manually, but it seems to also be the case when using 
composer (At least I got reports about failed SQL statements when 
installing with composer)

As far as I can see, SQL statements in roundcube codebase have no 
prefix, as my sql statements in my plugin. How are database prefix 
handled when installing roundcube? How are they handled when installing 
a plugin with composer? (ok, I found how, see below)

I have 2 concerns:
- One is table creation (CREATE TABLE statements), on which prefix 
should added. Is that handled automatically by composer? (It seems to be 
the case)
- The second one is foreign keys that reference roundcube standard 
tables like REFERENCES `users`(`user_id`) which should be changed to 
REFERENCES `PREFIX_users`(`user_id`). Is that automatically handled by 
composer at plugin installation? (It seems to be the missing one)

Is there any documentation for plugin coders on how to properly handle 
plugins databases with references to standard roundcube databases 
regarding database prefix?

As far as I can see here: 
This problem is already handled for CREATE DATABASE statements and for 
CREATE SEQUENCE statements but not for REFERENCES statements as used in 
the automatic_addressbook plugin here:

I should be able to propose a PR on plugin_installer for that. Is there 
something more I need to be aware of before coding?

Best regards and keep making such a good webmail!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.roundcube.net/pipermail/dev/attachments/20200105/fb1273ef/attachment.html>

More information about the dev mailing list