[development] D6 SAPI: using hook_install to ALTER {tables}

Augustin (Beginner) drupal.beginner at wechange.org
Thu Dec 27 08:15:58 UTC 2007


Hello,

I just read through the Schema API documentation:
http://drupal.org/node/146843


All the examples of hook_install() assume the module is creating a 
whole new table.

E.g. here
http://drupal.org/node/146862

and here:
http://api.drupal.org/api/function/hook_install
function hook_install() {
  drupal_install_schema('upload');
}


What if a contrib module wants to ALTER an existing table (created by 
another module)?

Q1) Do I still use hook_schema() to define the extra field and call it 
from hook_install() as in the examples?

Q2) Or, do I call db_add_field() from hook_install()?

Q3) Is it considered best practice to create your own tables rather 
than adding fields to existing tables "belonging" to other modules?



Blessings,

Augustin.



More information about the development mailing list