+ /**
+ * Compare the local database schema with the reference schema
+ * required for this version of Roundcube
+ *
+ * @param boolean True if the schema schould be updated
+ * @return boolean True if the schema is up-to-date, false if not or an error occured
+ */
+ function db_schema_check($DB, $update = false)
+ {
+ if (!$this->configured)
+ return false;
+
+ // simple ad hand-made db schema
+ $db_schema = array(
+ 'users' => array(),
+ 'identities' => array(),
+ 'contacts' => array(),
+ 'contactgroups' => array(),
+ 'contactgroupmembers' => array(),
+ 'cache' => array(),
+ 'messages' => array(),
+ 'session' => array(),
+ );
+
+ $errors = array();
+
+ // check list of tables
+ $existing_tables = $DB->list_tables();
+
+ foreach ($db_schema as $table => $cols) {
+ $table = !empty($this->config['db_table_'.$table]) ? $this->config['db_table_'.$table] : $table;
+ if (!in_array($table, $existing_tables))
+ $errors[] = "Missing table ".$table;
+ // TODO: check cols and indices
+ }
+
+ return !empty($errors) ? $errors : false;
+ }