<?php
function calendar_install() {
  $result = array();
  
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
        
      $result[] = db_query ("CREATE TABLE {calendar} (
        vid int(10) unsigned NOT NULL default '0',
        nid int(10) unsigned NOT NULL default '0',
        start_date date NOT NULL default '1000-01-01',
        allday tinyint(1) unsigned NOT NULL default '0',
        start int(11) NOT NULL default '0',
        end int(11) NOT NULL default '0',
        location varchar(255) NOT NULL default '',
        PRIMARY KEY (vid, nid),
        KEY `calendar_nid` (nid)
        ) ENGINE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
      
      break;
   
    case 'pgsql':
      break;
  }
  
  if (count($result) == count(array_filter($result))) {
  	drupal_set_message(t('The calendar module has successfully added its tables to the database.'));
  }
  else {
  	drupal_set_message(t('Drupal was unable to install the database tables for the calendar module.'), 'error');
  }
}
