Add a new table using the install file
This is how you should add a new table for your module in the install file using the hook_update_N in Drupal 6
<?php
/**
* Adds a new table for templates report creation loop
* 2015-08-16
* @return unknown
*/
function zimonitor_reporting_update_6003() {
$schema['reporting_report_loop'] = array(
'description' => "The report creation loop of a template",
'fields' => array(
'lid' => array(
'description' => 'Loop id',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'uid' => array(
'description' => 'User id',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'tplid' => array(
'type' => 'int',
'description' => 'Template id',
'unsigned' => TRUE,
'not null' => TRUE,
),
'start' => array(
'description' => 'Timestamp of loop start',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'end' => array(
'description' => 'Timestamp of loop end',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'time_period' => array(
'description' => 'Time period of the report',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'objects' => array(
'description' => 'Array of objects nid and its status',
'type' => 'text',
'not null' => TRUE,
'size' => 'medium',
),
'saved' => array(
'description' => 'Last saved',
'type' => 'int',
'not null' => TRUE,
'default' => 0
),
),
'primary key' => array('lid'),
'unique keys' => array('tplid_start' => array('tplid', '`start`')),
);
$ret = array();
db_create_table($ret, 'reporting_report_loop', $schema['reporting_report_loop']);
return $ret;
}
?>
Good source of Drupal hook_update_N functions
Knowledge keywords: