diff --git a/advagg.install b/advagg.install
index e09eaa6..4663ca2 100644
--- a/advagg.install
+++ b/advagg.install
@@ -255,6 +255,54 @@ function advagg_schema() {
   return $schema;
 }
 
+
+/**
+ * Upgrade AdvAgg previous verions (6.x-1.x & 7.x-1.x) to 7.x-2.x.
+ *
+ * Implements hook_update_N().
+ */
+function advagg_update_7200(&$sandbox) {
+  // Check and see if new tables exist.
+  $table_names = array_keys(advagg_schema());
+  $all_tables_exist = TRUE;
+  $missing_tables = array();
+  foreach ($table_names as $table_name) {
+    if (!db_table_exists($table_name)) {
+      $all_tables_exist = FALSE;
+      $missing_tables[] = $table_name;
+    }
+  }
+  // Bail if needed DB Tables exist.
+  if ($all_tables_exist) {
+    return t('Nothing needed to happen in Advanced CSS/JS Aggregation.');
+  }
+
+  // Remove all old advagg variables.
+  db_delete('variable')
+    ->condition('name', 'advagg%', 'LIKE')
+    ->execute();
+
+  // Remove old schema.
+  $tables_to_remove = array(
+    'cache_advagg',
+    'cache_advagg_files_data',
+    'cache_advagg_bundle_reuse',
+    'advagg_files',
+    'advagg_bundles',
+  );
+  foreach ($tables_to_remove as $table_to_remove) {
+    if (db_table_exists($table_to_remove)) {
+      db_drop_table($table_to_remove);
+    }
+  }
+
+  // Install new schema.
+  drupal_install_schema('advagg');
+
+  return t('Upgraded Advanced CSS/JS Aggregation to 7.x-2.x.');
+}
+
+
 /**
  * Implements hook_requirements().
  */
diff --git a/advagg.module b/advagg.module
index a3b6247..2236477 100644
--- a/advagg.module
+++ b/advagg.module
@@ -219,6 +219,11 @@ function advagg_cron() {
  *   TRUE: Get all advagg cache bins
  */
 function advagg_flush_caches($all_bins = FALSE) {
+  // Send back a blank array if aav table doesn't exist.
+  if (!db_table_exists('advagg_aggregates_versions')) {
+    return array();
+  }
+
   // Get list of cache bins to clear.
   $bins = array();
   $bins[] = 'cache_advagg_aggregates';
@@ -913,6 +918,14 @@ function advagg_merge_plans($css_js_groups, $plans) {
  *   The value of the advagg_enabled variable.
  */
 function advagg_enabled() {
+  // Disable AdvAgg if module needs to be upgraded from 1.x to 2.x.
+  if (!db_table_exists('advagg_aggregates_versions')) {
+    $GLOBALS['conf']['advagg_enabled'] = FALSE;
+    if (user_access(array('administer site configuration'))) {
+      drupal_set_message(t('Please run <a href="@link">database updates</a>. AdvAgg will remain disabled until done.', array('@link' => url('update.php'))), 'error');
+    }
+  }
+
   // Only run code below if advagg is enabled.
   if (variable_get('advagg_enabled', ADVAGG_ENABLED)) {
     // Do not use the cache if the disable cookie is set.
@@ -938,7 +951,6 @@ function advagg_enabled() {
     if (isset($_GET['advagg-debug']) && $_GET['advagg-debug'] == 1 && user_access('bypass advanced aggregation')) {
       $GLOBALS['conf']['advagg_debug'] = TRUE;
     }
-
   }
 
   return variable_get('advagg_enabled', ADVAGG_ENABLED);
