how to run new .install on installed module
Hi, Probably a simple problem but I don't find solution on d.o. I have a D6 contrib module that did not use database before, but now it does. The problem is that even though a .install file has been added, the database is not created in case the older version of the module is enabled already, not even after running /update.php. http://drupal.org/node/323314 explains that ".install file is run the first time a module is enabled" -- but how to make sure the initial database is installed on an existing module? Is the only solution to solve it via hook_update_N, detecting whether the table exists, and installing it -- even though in fact we are installing, not updating? Thanks, Tomáš
On Fri, Jan 09, 2009 at 09:51:41AM +0100, Tomáš Fülöpp wrote:
Hi,
Probably a simple problem but I don't find solution on d.o.
I have a D6 contrib module that did not use database before, but now it does. The problem is that even though a .install file has been added, the database is not created in case the older version of the module is enabled already, not even after running /update.php.
http://drupal.org/node/323314 explains that ".install file is run the first time a module is enabled" -- but how to make sure the initial database is installed on an existing module? Is the only solution to solve it via hook_update_N, detecting whether the table exists, and installing it -- even though in fact we are installing, not updating?
AFAIK this case has to be handled by update functions in your .install file. Regards Jan
On Fri, Jan 9, 2009 at 12:51 AM, Tomáš Fülöpp <tjfulopp@gmail.com> wrote:
Hi,
Probably a simple problem but I don't find solution on d.o.
I have a D6 contrib module that did not use database before, but now it does. The problem is that even though a .install file has been added, the database is not created in case the older version of the module is enabled already, not even after running /update.php.
http://drupal.org/node/323314 explains that ".install file is run the first time a module is enabled" -- but how to make sure the initial database is installed on an existing module? Is the only solution to solve it via hook_update_N, detecting whether the table exists, and installing it -- even though in fact we are installing, not updating?
If you're addin a database to an existing module then you need to define it in hook_install() for new sites and also in hook_update_N() for sites that have already installed. If you think that they might have the table installed for some reason then by all means call db_table_exists() and check first. Also be aware that implementations of hook_update_N() should *not* call hook_schema(). You need to have a copy of the schema in the update function. andrew
Thanks, guys; I've successfully solved that using hook_update_N now. Best regards, Tomáš (Vacilando) On Fri, Jan 9, 2009 at 10:22, andrew morton <drewish@katherinehouse.com>wrote:
On Fri, Jan 9, 2009 at 12:51 AM, Tomáš Fülöpp <tjfulopp@gmail.com> wrote:
Hi,
Probably a simple problem but I don't find solution on d.o.
I have a D6 contrib module that did not use database before, but now it does. The problem is that even though a .install file has been added, the database is not created in case the older version of the module is enabled already, not even after running /update.php.
http://drupal.org/node/323314 explains that ".install file is run the first time a module is enabled" -- but how to make sure the initial database is installed on an existing module? Is the only solution to solve it via hook_update_N, detecting whether the table exists, and installing it -- even though in fact we are installing, not updating?
If you're addin a database to an existing module then you need to define it in hook_install() for new sites and also in hook_update_N() for sites that have already installed. If you think that they might have the table installed for some reason then by all means call db_table_exists() and check first. Also be aware that implementations of hook_update_N() should *not* call hook_schema(). You need to have a copy of the schema in the update function.
andrew
participants (3)
-
andrew morton -
Jan Dittberner -
Tomáš Fülöpp