summaryrefslogtreecommitdiff
path: root/roundcubemail/installer/rcube_install.php
diff options
context:
space:
mode:
authorthomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c>2010-04-15 07:28:05 +0000
committerthomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c>2010-04-15 07:28:05 +0000
commitc7adbfff46a087d3a899cf08be61a025de05f5ee (patch)
treeb828954489ab629d96bc7037c455f9012b4ecf16 /roundcubemail/installer/rcube_install.php
parentbbe3c2010df9041645a60c76cc3d3694a3aa05eb (diff)
Add minimal database schema check to installer and update script
git-svn-id: https://svn.roundcube.net/trunk@3490 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/installer/rcube_install.php')
-rw-r--r--roundcubemail/installer/rcube_install.php43
1 files changed, 40 insertions, 3 deletions
diff --git a/roundcubemail/installer/rcube_install.php b/roundcubemail/installer/rcube_install.php
index b0d59fd29..ae568d223 100644
--- a/roundcubemail/installer/rcube_install.php
+++ b/roundcubemail/installer/rcube_install.php
@@ -40,8 +40,8 @@ class rcube_install
'addrbook_show_images' => 'show_images',
);
- // these config options are optional or can be set to null
- var $required_config = array('db_dsnw', 'des_key');
+ // these config options are required for a working system
+ var $required_config = array('db_dsnw', 'db_table_contactgroups', 'db_table_contactgroupmembers', 'des_key');
/**
* Constructor
@@ -325,6 +325,43 @@ class rcube_install
}
}
+ /**
+ * 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) {
+ if (!in_array($this->config['db_table_'.$table], $existing_tables))
+ $errors[] = "Missing table ".$table;
+
+ // TODO: check cols and indices
+ }
+
+ return !empty($errors) ? $errors : false;
+ }
/**
* Compare the local database schema with the reference schema
@@ -333,7 +370,7 @@ class rcube_install
* @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($update = false)
+ function mdb2_schema_check($update = false)
{
if (!$this->configured)
return false;