I need to create custom table for module, but after module install table is not created.

module.install file:

function bip_content_migration_schema() {

    $schema['bip_migrate'] = array(

            'description' => 'Storing content migration info from Joomla.',
            'fields' => array(

                    'id' => array(
                            'description' => 'id',
                            'type' => 'serial',
                    'content_type' => array(
                            'description' => 'content type',
                            'type' => 'varchar',
                            'not null' => TRUE,
                            'length' => 255,
                    'imported_count' => array(
                            'description' => 'imported count',
                            'type' => 'int',
                            'not null' => TRUE,
                            'default' => 0,
                    'to_import_count' => array(
                            'description' => 'to import count',
                            'type' => 'int',
                            'not_null' => TRUE,
                    'is_imported' => array(
                            'description' => 'is imported',
                            'type' => 'int',
                            'default' => 0,
            'primary key' => array('id'),
            'indexes' => array(
                    'id' => array('id'),
    return $schema;


What am I doing wrong?


I added functions to my .install file (thought that I can ommit theme)

function bip_content_migration_install() {

function bip_content_migration_uninstall() {

But again table is not created.

  • 1
    Have you after disabling your module, uninstalled it as well? I am thinking D7 won't look at this until you actually do the uninstall part that goes and deletes the DB tables. Then if you re-enable it, it will call the schema and install your table. Eg, The tables declared by this hook will be automatically created when the module is first enabled, and removed when the module is uninstalled. This happens before hook_install() is invoked, and after hook_uninstall() is invoked, respectively. from api.drupal.org/api/drupal/modules%21system%21system.api.php/…
    – Jimajamma
    Commented Aug 12, 2012 at 22:19
  • 1
    as @Jimajamma said, try Devel's re-install feature to re-installing your module and force drupal to call hook_schema() Commented Aug 12, 2012 at 22:23
  • How did you solve this issue ? what was the problem here
    – Hitesh
    Commented Sep 2, 2014 at 5:37

3 Answers 3


In Drupal 7, it is not necessary to call drupal_install_schema(), or drupal_uninstall_schema(); that is automatically done from Drupal. It is enough to implement hook_schema(), and the database table is created. There are many modules for Drupal 7 implementing that hook, and their database tables are created.

I can think of two possible causes for the database table not being created:

  • The short name of the module is not bip_content_migration
  • You added the hook_schema() implementation on an already installed module

If you installed the module, disabled it, changed the code, and re-enabled it, the database table would not be created. Disabling a module is different from uninstalling it. Uninstalling is done when a module is disabled, and then uninstalled from the "Uninstall" tab in admin/modules.


I didn't considered the following two cases, as Drupal should have given you some errors:

  • The schema is not correct
  • Drupal is not able to connect to the database, while installing the module.

If there are more databases, be sure you are looking at the right database.

  • but here it says drupal.org/node/876250 we need to use hook_install and hook_uninstall ...can you please explain do we need to use hook_install and hook_uninstall or not ?
    – Hitesh
    Commented Sep 2, 2014 at 5:39
  • The documentation has been copied from Drupal 6 documentation, it seems. That is what you had to do in Drupal 6.
    – apaderno
    Commented Sep 2, 2014 at 16:14
  • IN D7? do we not need it ?
    – Hitesh
    Commented Sep 3, 2014 at 7:20
  • You just need to implement hook_schema(), in Drupal 7.
    – apaderno
    Commented Sep 3, 2014 at 11:38

I know this is old but anyway. If you are trying to see changes on re-enable the module, first, you need to disable and uninstall the module. Use

drush dre [module]

More info here hook_schema is not creating database table


Disable the module. Search your module name in 'system' table name column(drupal database) and delete that particular column. Try again by enabling the module. your table will be created.

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.