diff --git a/nodequeue.install b/nodequeue.install
index 1c22186..49a3f22 100644
--- a/nodequeue.install
+++ b/nodequeue.install
@@ -410,21 +410,40 @@ function nodequeue_update_7300() {
     'length' => 128,
   );
 
+  // Fix subqueues.
+  $subqueues = db_select('nodequeue_subqueue', 'sq')
+    ->fields('sq', array('sqid'))
+    ->execute()
+    ->fetchCol();
+  $int = 10;
+  foreach ($subqueues as $subqueue) {
+    db_query('UPDATE {nodequeue_subqueue} SET sqid = :new WHERE sqid = :old', array(':new' => $int, ':old' => $subqueue));
+    db_query('UPDATE {nodequeue_nodes} SET sqid = :new WHERE sqid = :old', array(':new' => $int, ':old' => $subqueue));
+    $int++;
+  }
+  $def = array(
+    'description' => 'Subqueue identifier',
+    'type' => 'serial',
+    'unsigned' => TRUE,
+    'not null' => TRUE,
+  );
+  db_change_field('nodequeue_subqueue', 'sqid', 'sqid', $def);
+  $def = array(
+    'description' => 'Subqueue this node is in',
+    'type' => 'int',
+    'unsigned' => TRUE,
+    'not null' => TRUE,
+  );
+  db_change_field('nodequeue_nodes', 'sqid', 'sqid', $def);
+
   // Get an array map of qid/name values before deleting qid field from
   // nodequeue_queue table.
+  db_query('UPDATE {nodequeue_queue} SET name = qid');
   $queues = db_select('nodequeue_queue', 'nq')
     ->fields('nq', array('qid', 'name'))
     ->execute()
     ->fetchAllKeyed(0, 1);
 
-  // Changes to noqueue_queue table.
-  // Change qid from serial to int first, otherwise removing the primary key
-  // isn't possible.
-  db_change_field('nodequeue_queue', 'qid', 'qid', array(
-    'type' => 'int',
-    'unsigned' => TRUE,
-    'not null' => TRUE,
-  ));
   db_drop_primary_key('nodequeue_queue');
   db_drop_unique_key('nodequeue_queue', 'name');
   db_add_primary_key('nodequeue_queue', array('name'));
