diff --git a/blockcache_alter.install b/blockcache_alter.install
index ecb410e..b8311ab 100644
--- a/blockcache_alter.install
+++ b/blockcache_alter.install
@@ -46,4 +46,47 @@ function blockcache_alter_schema() {
   );
 
   return $schema;
-}
\ No newline at end of file
+}
+
+/**
+ * Add the "bid" column to {blockcache_alter} and backfill block IDs.
+ */
+function blockcache_alter_update_7000() {
+  // Ensure we don't run this update for existing installs; D6 updates only.
+  if (!db_field_exists('blockcache_alter', 'bid')) {
+    // Define the bid column and primary key.
+    $spec = array(
+      'type' => 'serial',
+      'not null' => TRUE,
+      'description' => 'Primary Key: Unique block ID.',
+    );
+    $keys = array(
+      'primary key' => array('bid'),
+    );
+
+    // Add the bid column along with the new primary key.
+    db_add_field('blockcache_alter', 'bid', $spec, $keys);
+
+    // If there are existing block cache alter entries, find their block IDs.
+    $bcas = db_select('blockcache_alter', 'bca', array('fetch' => PDO::FETCH_ASSOC))
+      ->fields('bca');
+    $bcas->join('block', 'b', 'bca.module = %alias.module AND bca.delta = %alias.delta');
+    $bcas->fields('b', array('bid'));
+    $results = $bcas->execute();
+
+    // If results were returned, truncate the existing block cache alter table,
+    // then insert all of the database records we previously found/built.
+    if (!empty($results)) {
+      db_truncate('blockcache_alter')->execute();
+
+      $insert = db_insert('blockcache_alter')
+        ->fields(array('module', 'delta', 'cache', 'bid'));
+
+      foreach ($results as $bca) {
+        $insert->values($bca);
+      }
+
+      $insert->execute();
+    }
+  }
+}
diff --git a/blockcache_alter.module b/blockcache_alter.module
index 17c62f4..3c8cee0 100644
--- a/blockcache_alter.module
+++ b/blockcache_alter.module
@@ -95,10 +95,16 @@ function blockcache_alter_save_settings($form, &$form_state) {
  */
 function blockcache_alter_block_info_alter(&$blocks, $theme, $code_blocks) {
 
-  $blockcache_alter = db_select('blockcache_alter', 'b')
-    ->fields('b', array('bid', 'module', 'cache'))
-    ->execute()
-    ->fetchAll();
+  try {
+    $blockcache_alter = db_select('blockcache_alter', 'b')
+      ->fields('b', array('bid', 'module', 'cache'))
+      ->execute()
+      ->fetchAll();
+  }
+  catch (PDOException $e) {
+    $blockcache_alter = array();
+    watchdog('blockcache alter', 'Block cache alter was unable to load block cache data. You may need to run updates.', array(), WATCHDOG_ERROR);
+  }
 
   foreach ($blockcache_alter as $bca) {
     if (array_key_exists($bca->module, $blocks)) {
