I am creating a table using hook_schema()

I am referring phpMyadmin to create a new table. In the phpMyadmin there is a
column 'Attributes'

which has values as 'unsigned' or on update CURRENT_TIMESTAMP' I have a row in a table which is of type 'timestamp' and has attributes 'on update CURRENT_TIMESTAMP'.
How can I include this attribute on update CURRENT_TIMESTAMP in the hook_schema() ?

Also there is a default column in phpMyAdmin how can I add that in hook_schema() ?

the first time I created a hook_module_name.install a table was created as it was specified in the hook_schema()

Then I uninstalled that module but the table was not deleted ? Now I even removed the .install file cleared the cache , even after this a table is not created. What can be the solution to this problem.

What I have checked is that it is entering into hook_schema function but the table is not generated at the database. Any hints on this would be appreciated.

  • Hello. Please avoid chameleon questions. I strongly suggest rollback and asking future questions using "Ask Question" button.
    – Mołot
    Commented Sep 16, 2013 at 10:18
  • ok. I am sorry..
    – harshal
    Commented Sep 16, 2013 at 10:20
  • No problem :) Keeping things clear and questions stable makes it easier to find answers, and more encouraging to answer - the only reason I mentioned it was to keep this site and community able and willing to provide what you need. You've read and applied, great. No reason to feel bad about mistakes that got corrected.
    – Mołot
    Commented Sep 16, 2013 at 10:24

1 Answer 1


You can't use an ON UPDATE unfortunately - Drupal's schema API doesn't give you that sort of dbms-specific control.

You can use unsigned for unsigned and default for a default value though:

$schema['some_table'] = array(
  'fields' => array(
    'some_field' => array(
      'type' => 'int',
      'not null' => TRUE,
      'unsigned' => TRUE,
      'default' => 0,

See the Schema API docs for the full list of data types and usage.

  • pls check updated question? I am not able to generate or remove a table on enabling or disabling a module
    – harshal
    Commented Sep 16, 2013 at 9:11
  • I'd wager you didn't uninstall the module, and just disabled it. There's an 'uninstall' tab you need to visit once disabling the module (or run drush pm-uninstall)
    – Clive
    Commented Sep 16, 2013 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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