Hi i am leaarning creating install file. I want to create new table. I create very simple .install file but table is not creating. Coud anybody help me?


function mymodule_install() {
  // Create tables.
  drupal_install_schema('mymodule');
}

function mymodule_schema() {
  $schema['mymodule'] = array(
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t('description....'),
      ),
     ),
  );
  return $schema;
}

function mymodule_uninstall() {
  drupal_uninstall_schema('mymodule');
}

Comments

jaypan’s picture

hook_schema() is only called on first install, not on subsequent module enables. So you will need to disable the module, click the uninstall tab, uninstall the module, then re-install it.

Contact me to contract me for D7 -> D10/11 migrations.

tomas.teicher’s picture

thank you,
that was the problem
Tomas