How do I add column to existing table on module installation? I want to add an extra field to the users table from a custom module. I am not sure how exactly can it be done. I'm sure it is done in mymodule.install file.
Should I use db_add_field, or is there any other way? And where should I implement it? hook_schema (but the schema is already defined), or hook_install?
For the sake of giving a (hopefully) complete answer:


You will need to alter the schema of an existing module, signalling the change to the system. So implement hook_schema_alter().
You will need to implement hook_install() to actually add the field to the database.
You will need to implement hook_uninstall() as well, to remove the extra field when the module is uninstalled. You might need to do extra cleanup at this stage.


An example which alters the Webform module's webform_submitted_data table:

function MYMODULE_schema_alter(&amp;$schema) {
  $schema['webform_submitted_data']['fields']['extra'] = array(
    'description' =&gt; 'Some random extra info.',
    'type' =&gt; 'text',
    'size' =&gt; 'big',
  );
}

function MYMODULE_install() {
  db_add_field('webform_submitted_data', 'extra', array(
    'description' =&gt; 'Some random extra info.',
    'type' =&gt; 'text',
    'size' =&gt; 'big',
  ));
}

function MYMODULE_uninstall() {
  db_drop_field('webform_submitted_data', 'extra');
}