I have a question about the module install process. I am developing a module that will have 2 tables. How should I produce this within the hook_schema? Do need to call 2 different drupal_install_schema from within the install function, or wold I all the table inserts within one module_schema() function?

this?

[code]
function module_install()
{
drupal_install_schema('module');
}
module_schema()
{
$schema['module_table_1'] = array(
'fields' => array(
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
)
)
);
$schema['module_table_2']
'fields' => array(
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
)
)
);
}
[/code]

or this?

[code]
function module_install()
{
drupal_install_schema('module');
drupal_install_schema('module_tbl_2');
}
[/code]

Comments

yfreeman’s picture

the $schema variable is an array of tables.

function module_schema(){
  $schema= array();
  $schema["table1"] = array(...); // table1 schema
  $schema["table2"] = array(...);// table 2 schem 
  etc.

  return $schema;

}

to install both tables you just install the schema

function module_install(){
  drupal_install_schema('module');// where module== name of your module
}
fuzzyjared’s picture

Thanks that is the answer that I was looking for.