Trying to write a .install file for a module and I read through here:
http://drupal.org/node/51220
However, I still cannot get my module to create the table I need.
Hoping someone can point me in the right direction.
Here is the code:
<?php
// item_close.install
function item_close_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
// the {tablename} syntax is so multisite installs can add a
// prefix to the table name as set in the settings.php file
db_query("CREATE TABLE {pm_item_close} (
nid int unsigned NOT NULL default '0',
vid int unsigned NOT NULL default '0',
item_close_date int unsigned NOT NULL default '0',
PRIMARY KEY (vid)
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
case 'pgsql':
db_query("CREATE TABLE {pm_item_close} (
nid serial CHECK (nid >= 0),
vid serial CHECK (vid >= 0),
item_close_date serial CHECK (item_close_date >= 0),
PRIMARY KEY (vid)
)");
// Pgsql requires keys and indexes to be defined separately.
// It's important to name the index as {tablename}_fieldname_idx
// (the trailing _idx!) so update scripts can be written easily
db_query("CREATE INDEX {item_close}_field_name_idx
ON {my_table} (field_name)");