Index: modules/tracker/tracker.install
===================================================================
RCS file: modules/tracker/tracker.install
diff -N modules/tracker/tracker.install
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/tracker/tracker.install	24 Aug 2009 01:36:55 -0000
@@ -0,0 +1,204 @@
+<?php
+// $Id$
+
+/**
+ * Implement hook_install().
+ */
+function tracker_install() {
+  // Create tables.
+  drupal_install_schema('tracker');
+}
+
+/**
+ * Implement hook_uninstall().
+ */
+function tracker_uninstall() {
+  // Remove tables
+  drupal_uninstall_schema('tracker');
+
+  variable_del('tracker_index_nid');
+  variable_del('tracker_batch_size');
+}
+
+/**
+ * Implement hook_enable().
+ */
+function tracker_enable() {
+  $max_nid = db_query('SELECT MAX(nid) FROM {node}')->fetchField();
+  if ($max_nid != 0) {
+    variable_set('tracker_index_nid', $max_nid);
+    tracker_cron();
+  }
+}
+
+/**
+ * Implement hook_schema().
+ */
+function tracker_schema() {
+  $schema['tracker_node'] = array(
+    'description' => 'Stores information about node.',
+    'fields' => array(
+      'nid' => array(
+        'description' => 'The node ID.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'published' => array(
+        'description' => 'Boolean indicating whether the node is published.',
+        'type' => 'int',
+        'not null' => FALSE,
+        'default' => 0,
+        'size' => 'tiny',
+      ),
+      'changed' => array(
+        'description' => 'The Unix timestamp when the node was most recently saved.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+    ),
+    'indexes' => array(
+      'tracker' => array('published', 'changed'),
+    ),
+    'primary key' => array('nid'),
+  );
+
+  $schema['tracker_user'] = array(
+    'description' => 'Stores information about node per user.',
+    'fields' => array(
+      'nid' => array(
+        'description' => 'The node ID.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'uid' => array(
+        'description' => 'The user ID.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'published' => array(
+        'description' => 'Boolean indicating whether the node is published.',
+        'type' => 'int',
+        'not null' => FALSE,
+        'default' => 0,
+        'size' => 'tiny',
+      ),
+      'changed' => array(
+        'description' => 'The Unix timestamp when the node was most recently saved.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+    ),
+    'indexes' => array(
+      'tracker' => array('uid', 'published', 'changed'),
+    ),
+    'primary key' => array('nid', 'uid'),
+  );
+
+  return $schema;
+}
+
+/**
+ * @defgroup updates-6.x-to-7.x Tracker updates from 6.x to 7.x
+ * @{
+ */
+
+/**
+ * Create new tracker_node and tracker_user tables.
+ */
+function tracker_update_7000() {
+    $schema['tracker_node'] = array(
+    'description' => 'Stores information about node.',
+    'fields' => array(
+      'nid' => array(
+        'description' => 'The nid of the node.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'published' => array(
+        'description' => 'Boolean indicating whether the node is published.',
+        'type' => 'int',
+        'not null' => FALSE,
+        'default' => 0,
+        'size' => 'tiny',
+      ),
+      'changed' => array(
+        'description' => 'The Unix timestamp when the node was most recently saved.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+    ),
+    'indexes' => array(
+      'tracker' => array('published', 'changed'),
+    ),
+    'primary key' => array('nid'),
+  );
+
+  $schema['tracker_user'] = array(
+    'description' => 'Stores information about node per user.',
+    'fields' => array(
+      'nid' => array(
+        'description' => 'The id of the node.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'uid' => array(
+        'description' => 'The id of the user.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'published' => array(
+        'description' => 'Boolean indicating whether the node is published.',
+        'type' => 'int',
+        'not null' => FALSE,
+        'default' => 0,
+        'size' => 'tiny',
+      ),
+      'changed' => array(
+        'description' => 'The Unix timestamp when the node was most recently saved.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+    ),
+    'indexes' => array(
+      'tracker' => array('uid', 'published', 'changed'),
+    ),
+    'primary key' => array('nid', 'uid'),
+  );
+
+  $ret = array();
+  foreach ($schema as $name => $table) {
+    db_create_table($ret, $name, $table);
+  }
+
+  $max_nid = db_query('SELECT MAX(nid) FROM {node}')->fetchField();
+  if ($max_nid != 0) {
+    variable_set('tracker_index_nid', $max_nid);
+    drupal_set_message(t('Tracker will index from node %nid downward.', array('%nid' => $max_nid)));
+  }
+  return $ret;
+}
+
+/**
+ * @} End of "defgroup updates-6.x-to-7.x"
+ * The next series of updates should start at 8000.
+ */
