New database update system that uses the database structure defined in dbstructure.php

This commit is contained in:
Michael Vogel 2014-06-04 00:44:58 +02:00
parent e729d2e216
commit 0c77cee667
4 changed files with 380 additions and 328 deletions

View File

@ -1000,6 +1000,10 @@ if(! function_exists('update_db')) {
if(DB_UPDATE_VERSION == UPDATE_VERSION) {
// Compare the current structure with the defined structure
require_once("include/dbstructure.php");
update_structure(false, true);
for($x = $stored; $x < $current; $x ++) {
if(function_exists('update_' . $x)) {

File diff suppressed because it is too large Load Diff

View File

@ -498,7 +498,10 @@ function load_database_rem($v, $i){
function load_database($db) {
$str = file_get_contents('database.sql');
require_once("include/dbstructure.php");
$errors = update_structure(false, true);
/* $str = file_get_contents('database.sql');
$arr = explode(';',$str);
$errors = false;
foreach($arr as $a) {
@ -508,7 +511,8 @@ function load_database($db) {
$errors .= t('Errors encountered creating database tables.') . $a . EOL;
}
}
}
}*/
return $errors;
}

View File

@ -26,10 +26,9 @@ define( 'UPDATE_VERSION' , 1170 );
* The DB_UPDATE_VERSION will always be one greater than the last numbered script in this file.
*
* If you change the database schema, the following are required:
* 1. Update the file database.sql to match the new schema.
* 2. Update this file by adding a new function at the end with the number of the current DB_UPDATE_VERSION.
* This function should modify the current database schema and perform any other steps necessary
* to ensure that upgrade is silent and free from requiring interaction.
* 1. Update the file include/dbstructure.php to match the new schema.
* 2. If there is a need for a post procession, update this file by adding a new function at the end with the number of the current DB_UPDATE_VERSION.
* This function should perform some post procession steps but no database updates.
* 3. Increment the DB_UPDATE_VERSION in boot.php *AND* the UPDATE_VERSION in this file to match it
* 4. TEST the upgrade prior to checkin and filing a pull request.
*