diff --git a/database/updates.inc b/database/updates.inc
index c7192509ea6bc8fe811f46e02e11fde3733813dd..095176103c7e531cc154b9955d6b6314787208ce 100644
--- a/database/updates.inc
+++ b/database/updates.inc
@@ -667,6 +667,13 @@ function system_update_144() {
 
 function system_update_145() {
   $default_theme = variable_get('theme_default', 'bluemarine');
+
+  $themes = list_themes();
+  if (!array_key_exists($default_theme, $themes)) {
+      variable_set('theme_default', 'bluemarine');
+      $default_theme = 'bluemarine';
+   }
+
   $ret = array();
 
   switch ($GLOBALS['db_type']) {