0

I have to add a field to the webform table generated by the webform contrib module.

I was thinking about implementing the enable hook in the .install of a custom module in order to do this:

function mymodule_enable( ) {                                                
  db_query('ALTER TABLE webform ADD COLUMN is_valid int') ;
} 

But I don't know if this will generate problems if the module is disabled and enabled again in the future and tries to add the field (which would be already created by then).

Is this correct or is there a better way to do this?

  • i would make a separate table for you module. at least if you remove your module you are not touching the schema out there. you may also want to check drupal.org/node/146843 for schema api – au_stan May 11 '12 at 13:12
  • Unfortunately that it's not an option, I have to add the new field in the webform table. – rfc1484 May 11 '12 at 13:27
  • well then i think you know your answer. looks like you'll need to alter the webform table. just curious, why is a separate table not an option for you? – au_stan May 11 '12 at 13:42
2

Well, you could always use hook_update to generate a new field in the table. This gets executed when you do a database update.

It's even possible to use it in your own module.

http://api.drupal.org/api/drupal/modules!node!node.api.php/function/hook_update/7

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.