<?php
  // aggregator2.install,v 1.2 2006/04/01 02:56:40 budda Exp

  function aggregator2_install() {
    switch ($GLOBALS['db_type']) {
      case 'mysqli':
      case 'mysql':
      db_query("CREATE TABLE {aggregator2_feed} (
        `nid` int(10) NOT NULL default '0',
        `author` varchar(60) NOT NULL default '',
        `freezed` int(4) NOT NULL default '0',
        `url` varchar(255) NOT NULL default '',
        `refresh` int(10) NOT NULL default '0',
        `clear_items` int(10) NOT NULL default '1000000000',
        `update_items` int(4) NOT NULL default '1',
        `guid_items` int(4) NOT NULL default '0',
        `promoted_items` int(10) NOT NULL default '1000000000',
        `checked` int(10) NOT NULL default '0',
        `link` varchar(255) NOT NULL default '',
        `image` longtext NOT NULL,
        `etag` varchar(255) NOT NULL default '',
        `modified` int(10) NOT NULL default '0',
        `item_status` int(4) NOT NULL default '0',
        `item_taxonomy` longtext NOT NULL,
        `item_date_source` tinyint(3) unsigned NOT NULL default '0',
        `item_show_link` tinyint(3) unsigned NOT NULL default '0',
        `item_delete_mode` int(4) NOT NULL default '0',
        PRIMARY KEY  (`nid`),
        UNIQUE KEY `url` (`url`)
      ) TYPE=MyISAM;");

      db_query("CREATE TABLE {aggregator2_item} (
        `nid` int(10) NOT NULL default '0',
        `fid` int(10) unsigned NOT NULL default '0',
        `author` varchar(60) NOT NULL default '',
        `link` varchar(255) NOT NULL default '',
        `guid` varchar(255) NOT NULL default '',
        `source_link` varchar(255) NOT NULL default '',
        `source_title` varchar(128) NOT NULL default '',
        PRIMARY KEY  (`nid`),
        KEY `fid` (`fid`),
        KEY `link` (`link`),
        KEY `guid` (`guid`)
      ) TYPE=MyISAM;");

      $success = TRUE;
      break;
    case 'pgsql':

      break;
    default:
      break;
  } // End case

  if ($success) {
    drupal_set_message(t('Aggregator2 module installed tables successfully.'));
  }
  else {
    drupal_set_message(t('The installation of Aggregator2 module was unsuccessful.'), 'error');
  }
}