Changeset 3490 in subversion


Ignore:
Timestamp:
Apr 15, 2010 3:28:05 AM (3 years ago)
Author:
thomasb
Message:

Add minimal database schema check to installer and update script

Location:
trunk/roundcubemail
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/UPGRADING

    r2578 r3490  
    22====================== 
    33 
    4 First you should remove all subfolders from /program/localization/ 
    5 because most language codes have changed in 0.2-alpha. This way you 
    6 can make sure that no old localization files remain on your disk. 
    7  
    8 Then follow these instructions if upgrading from a previous version 
    9 of RoundCube Webmail. 
     4Follow these instructions if upgrading from a previous version 
     5of Roundcube Webmail. We recommend to carefully backup the existing 
     6installation as well as the database before executig the following steps. 
    107 
    1181. Replace index.php and all files in 
     
    1714   - ./plugins/ 
    18152. Run ./bin/update.sh from the commandline OR 
    19    open http://url-to-roundcube/installer/ in a browser. To enable 
    20    the latter one, you have to temporary set 'enable_installer' to true 
     16   open http://url-to-roundcube/installer/ in a browser and choose "3 Test config". 
     17   To enable the latter one, you have to temporary set 'enable_installer' to true 
    2118   in your local config/main.inc.php file. 
    22193. Let the update script/installer check your configuration and 
     
    2926 
    3027 
    31 For manually upgrading your RoundCube installation follow the instructions 
    32 that match the currently installed version: 
    33  
    34 from version 0.2-alpha 
    35 ---------------------------------------- 
    36 * replace index.php 
    37 * replace all files in folder /bin/ 
    38 * replace all files in folder /program/ 
    39 * replace all files in folder /installer/ 
    40 * replace all files in folder /skins/default/ 
    41 * run all commands in SQL/[yourdbtype].update.sql 
    42   below the line "-- Updates from version 0.2-alpha" 
    43 * check the config/main.inc.php.dist for new configuration  
    44   options and add them to your config  
    45   WARNING: 'skin_path' option was replaced by 'skin' option 
    46 * WARNING: 'db_backend' option has been removed, now only 
    47   PEAR::MDB2 driver is supported 
    48  
    49  
    50 from version 0.1.1 
    51 ---------------------------------------- 
    52 * replace index.php 
    53 * replace all files in folder /bin/ 
    54 * replace all files in folder /program/ 
    55 * replace all files in folder /skins/default/ 
    56 * run all commands in SQL/[yourdbtype].update.sql 
    57   below the line "-- Updates from version 0.1.1" 
    58 * check the config/main.inc.php.dist for new configuration  
    59   options and add them to your config  
    60  
    61  
    62 from version 0.1-stable 
    63 ---------------------------------------- 
    64 * replace index.php 
    65 * replace all files in folder /bin/ 
    66 * replace all files in folder /program/ 
    67 * replace all files in folder /skins/default/ 
    68 * run all commands in SQL/[yourdbtype].update.sql 
    69 * check the config/main.inc.php.dist for new configuration options 
    70   and add them to your config  
    71  
    72  
    73 from version 0.1-rc2 
    74 ---------------------------------------- 
    75 * replace index.php 
    76 * replace all files in folder /bin/ 
    77 * replace all files in folder /program/ 
    78 * replace all files in folder /skins/default/ 
    79 * run all commands in SQL/[yourdbtype].update.sql 
    80  
    81  
    82 from version 0.1-rc1 
    83 ---------------------------------------- 
    84 * replace index.php 
    85 * replace all files in folder /bin/ 
    86 * replace all files in folder /program/ 
    87 * replace all files in folder /skins/default/ 
    88 * If you have LDAP servers configured you should re-configure 
    89   the config entries using the template given in /config/main.inc.php.dist 
    90  
    91  
    92 from version 0.1-beta2 
    93 ---------------------------------------- 
    94 * replace index.php 
    95 * replace all files in folder /bin/ 
    96 * replace all files in folder /program/ 
    97 * replace all files in folder /skins/default/ 
    98 * run all commands in SQL/[yourdbtype].update.sql or 
    99   re-initalize the database with [yourdbtype].initial.sql 
    100 * add these lines to /config/main.inc.php 
    101    $rcmail_config['draft_autosave'] = 300; 
    102    $rcmail_config['date_today'] = 'H:i'; 
    103 * If you have LDAP servers configured you should re-configure 
    104   the config entries using the template given in /config/main.inc.php.dist 
    105  
    106  
    107 form version 0.1-beta 
    108 ---------------------------------------- 
    109 * replace index.php 
    110 * replace all files in folder /bin/ 
    111 * replace all files in folder /program/ 
    112 * replace all files in folder /skins/default/ 
    113 * run all commands in SQL/[yourdbtype].update.sql or 
    114   re-initalize the database with [yourdbtype].initial.sql 
    115 * add this line to /config/db.inc.php 
    116    $rcmail_config['db_persistent'] = false; 
    117 * add these lines to /config/main.inc.php 
    118    $rcmail_config['drafts_mbox'] = 'Drafts'; 
    119    $rcmail_config['junk_mbox'] = 'Junk'; 
    120    $rcmail_config['product_name'] = 'RoundCube Webmail'; 
    121    $rcmail_config['read_when_deleted'] = false; 
    122    $rcmail_config['enable_spellcheck'] = false; 
    123    $rcmail_config['protect_default_folders'] = false; 
    124 * replace the following line from /config/main.inc.php 
    125    @include($_SERVER['HTTP_HOST'].'.inc.php'); 
    126   with  
    127    $rcmail_config['include_host_config'] = false; 
  • trunk/roundcubemail/bin/update.sh

    r2229 r3490  
    1313 
    1414if ($RCI->configured) { 
     15  $success = true; 
     16   
    1517  if ($messages = $RCI->check_config()) { 
     18    $success = false; 
    1619    $err = 0; 
    1720 
     
    101104      echo "See ya.\n"; 
    102105    } 
     106  } 
    103107 
     108  // check database schema 
     109  if ($RCI->config['db_dsnw']) { 
     110    $DB = new rcube_mdb2($RCI->config['db_dsnw'], '', false); 
     111    $DB->db_connect('w'); 
     112    if ($db_error_msg = $DB->is_error()) { 
     113      echo "Error connecting to database: $db_error_msg\n"; 
     114      $success = false; 
     115    } 
     116    else if ($RCI->db_schema_check($DB, false)) { 
     117      $updatefile = INSTALL_PATH . 'SQL/' . $DB->db_provider . '.update.sql'; 
     118      echo "WARNING: Database schema needs to be updated!\n"; 
     119      echo "Open $updatefile and execute all queries that are superscribed with the currently installed version number\n"; 
     120      $success = false; 
     121    } 
    104122  } 
    105   else { 
     123   
     124   
     125  if ($success) { 
    106126    echo "This instance of RoundCube is up-to-date.\n"; 
    107127    echo "Have fun!\n"; 
  • trunk/roundcubemail/installer/rcube_install.php

    r3442 r3490  
    4141  ); 
    4242   
    43   // these config options are optional or can be set to null 
    44   var $required_config = array('db_dsnw', 'des_key'); 
     43  // these config options are required for a working system 
     44  var $required_config = array('db_dsnw', 'db_table_contactgroups', 'db_table_contactgroupmembers', 'des_key'); 
    4545   
    4646  /** 
     
    326326  } 
    327327   
    328    
    329328  /** 
    330329   * Compare the local database schema with the reference schema 
     
    334333   * @return boolean True if the schema is up-to-date, false if not or an error occured 
    335334   */ 
    336   function db_schema_check($update = false) 
     335  function db_schema_check($DB, $update = false) 
     336  { 
     337    if (!$this->configured) 
     338      return false; 
     339     
     340    // simple ad hand-made db schema 
     341    $db_schema = array( 
     342      'users' => array(), 
     343      'identities' => array(), 
     344      'contacts' => array(), 
     345      'contactgroups' => array(), 
     346      'contactgroupmembers' => array(), 
     347      'cache' => array(), 
     348      'messages' => array(), 
     349      'session' => array(), 
     350    ); 
     351     
     352    $errors = array(); 
     353     
     354    // check list of tables 
     355    $existing_tables = $DB->list_tables(); 
     356    foreach ($db_schema as $table => $cols) { 
     357      if (!in_array($this->config['db_table_'.$table], $existing_tables)) 
     358        $errors[] = "Missing table ".$table; 
     359       
     360      // TODO: check cols and indices 
     361    } 
     362     
     363    return !empty($errors) ? $errors : false; 
     364  } 
     365   
     366  /** 
     367   * Compare the local database schema with the reference schema 
     368   * required for this version of RoundCube 
     369   * 
     370   * @param boolean True if the schema schould be updated 
     371   * @return boolean True if the schema is up-to-date, false if not or an error occured 
     372   */ 
     373  function mdb2_schema_check($update = false) 
    337374  { 
    338375    if (!$this->configured) 
  • trunk/roundcubemail/installer/test.php

    r3437 r3490  
    165165        $db_working = false; 
    166166    } 
    167   /* 
    168     else if (!$RCI->db_schema_check($update = !empty($_POST['updatedb']))) { 
     167    else if ($RCI->db_schema_check($DB, $update = !empty($_POST['updatedb']))) { 
    169168        $RCI->fail('DB Schema', "Database schema differs"); 
    170          
    171         echo $update ? '<p class="warning">Failed to update the database schema! Please manually execute the SQL statements from the SQL/*.update.sql file on your database</p>' : 
    172           '<p><input type="submit" name="updatedb" value="Update schema now" /></p>'; 
     169        $updatefile = INSTALL_PATH . 'SQL/' . $DB->db_provider . '.update.sql'; 
     170        echo '<p class="warning">Please manually execute the SQL statements from '.$updatefile.' on your database</p>'; 
    173171        $db_working = false; 
    174172    } 
    175   */ 
    176173    else { 
    177174        $RCI->pass('DB Schema'); 
Note: See TracChangeset for help on using the changeset viewer.