--- nodeapi_example/nodeapi_example.install	2009-10-14 18:51:34.000000000 -0500
+++ nodeapi_example/nodeapi_exampleNew.install	2010-06-16 16:57:46.000000000 -0500
@@ -26,10 +26,34 @@ function nodeapi_example_uninstall() {
 function nodeapi_example_schema() {
   $schema['nodeapi_example'] = array(
     'fields' => array(
-      'nid'    => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
-      'rating' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'id' => array(
+        'type' => 'serial',
+        'not null' => TRUE,
+        'description' => t('Primary Key: Unique ID.'),
+      ),
+      'nid' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+        'description' => t('node id for the rating'),
+      ),
+      'vid' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+        'description' => t('version id for rating'),
+      ),
+      'rating' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+        'description' => t('rating for this node'),
+      )
     ),
-    'primary key' => array('nid'),
+    'primary key' => array('id')
   );
 
   return $schema;
@@ -38,3 +62,32 @@ function nodeapi_example_schema() {
 function nodeapi_example_update_1() {
   return _system_update_utf8(array('nodeapi_example'));
 }
+
+/**
+ * Add an id field so we can have a unique id per row
+ * Add a vid field so we can include ratings in node revisions
+ */
+function nodeapi_example_update_6002() {
+  $ret = array();
+  db_add_field($ret, 'nodeapi_example', 'id',
+    array(
+      'type' => 'serial',
+      'not null' => TRUE,
+      'description' => t('Primary Key: Unique ID.'),
+    ),
+    array(
+      'primary key' => array('id')
+    ),
+  );
+  db_add_field($ret, 'nodeapi_example', 'vid',
+    array(
+      'type' => 'int',
+      'unsigned' => TRUE,
+      'not null' => TRUE,
+      'initial' => 0,
+      'default' => 0,
+      'description' => t('Revision id')
+    ),
+  );
+  return $ret;
+}
