--- usernode.install	2007-10-12 14:27:09.000000000 +0000
+++ usernode.install	2008-11-17 15:01:01.000000000 +0000
@@ -3,29 +3,36 @@
 
 if (!defined('USERNODE_CONTENT_TYPE')) {
   //if the module isn't included yet, we need to make this define so that things are working...
-  define('USERNODE_CONTENT_TYPE', "usernode");
+  define('USERNODE_CONTENT_TYPE', 'usernode');
+}
+
+function usernode_schema() {
+  $schema = array();
+
+  $schema['usernode'] = array(
+    'description' => 'Relates uid in the {user} table with nid in the {node} table.',
+    'fields' => array(
+      'nid' => array(
+        'type' => 'int',
+        'unsigned' => true,
+        'not null' => true,
+        'disp-width' => '10'
+      ),
+      'uid' => array(
+        'type' => 'int',
+        'unsigned' => true,
+        'not null' => true,
+        'disp-width' => '10'
+      )
+    ),
+    'primary key' => array('uid', 'nid')
+  );
+
+  return $schema;
 }
 
 function usernode_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysqli':
-    case 'mysql':
-      db_query("CREATE TABLE if not exists {usernode} (
-        nid int(10) unsigned NOT NULL,
-        uid int(10) unsigned NOT NULL,
-        PRIMARY KEY(uid,nid)
-      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
-      break;
-    case 'pgsql':
-      db_query("CREATE TABLE {usernode} (
-        nid int_unsigned NOT NULL,
-        uid int_unsigned NOT NULL,
-        PRIMARY KEY(uid,nid)
-      )");
-      break;
-    default:
-      break;
-  }
+  drupal_install_schema('usernode');
 
   // Prevent the promotion of new usernode objects to the front page by default,
   // by only placing 'status' (the 'Published' option) into the node options.
@@ -38,14 +45,14 @@
   // so let's find and delete the usernodes manually
   $result = db_query("SELECT u.* FROM {users} u ".
                      "JOIN {node} n ON u.uid = n.uid ".
-                     "WHERE n.type = '". USERNODE_CONTENT_TYPE ."'");
+                     "WHERE n.type = '%s'", USERNODE_CONTENT_TYPE);
 
   while ($user = db_fetch_object($result)) {
     usernode_delete_node($user);
   }
 
-  db_query("DROP TABLE {usernode}");
-  db_query("DELETE FROM {node_type} WHERE type = '". USERNODE_CONTENT_TYPE ."'");
+  drupal_uninstall_schema('usernode');
+  db_query("DELETE FROM {node_type} WHERE type = '%s'", USERNODE_CONTENT_TYPE);
   variable_del('node_options_'. USERNODE_CONTENT_TYPE);
 }
 
